Secrets of the Pulse - The Ancient Art of Ayurvedic Pulse Diagnosis
Hans Berger
Automating with STEP 7 in LAD and FBD 51MATIC 57·300/400 Programmable Controllers
SIEMENS
Hans·Berger
Automating with STEP 7 inLAD and FBD wooer diagram (LAO) "nd function block diagram (FSD) ~re the graphic-<:>rient.. rl pro9ram min9lan9u a9~ in the prog r~mmi n9 .~oftwaraSTEP 7. Now,n it< fourth ~>dj.lj.orl, this book tntwd uce, in the late,t ver<.ion of STEP 7 w ith new function~. 1\ de,cribe, e lemen ts arld_~pp l icJtion"'lo.. o"" with both SIMATIC 57'100 and 5IMATIC.57·400mduding the a pp lications w ilh PROFINET. ·Speda l lu nciions He PROF INET 10 , SFC 109 Protect and function bloc~< for fieldbu~ !y<; tems
Contents
Operation pri n~ieje of programmable conl
Ord~r N<>. A19100 153HI951-X_7600 4" edition, 2008
Publicis Corporate Pllblishing www.publids ..Jelbook~
-
-
Automating with STEP7 in LAD and FBD Programmable Controllers
51MATIC 57-300/ 40 0 by Hans Berger
4th revised and extended edition, 2008
Publicls Corporate Publishing
HiblioiJ1lphic: information publi.hed by the Ikut""he N.tionalbibliom..k The Dc-uttehe Narionall';bliom..k liM. this publication in th~ Dnnsch~ Natiooalbibliopfle: detailed bibliolV"pJ",; data:lre ",... ilablc LIt the lnlCmC1 al hup :l'dnb.d-nb.~.
Th" Jlt b. talen in order 10 comp ly with 11>0 ",I_ ""ani safely "'liIu l"i"" •.
,hi.
The luthOO" and pub'is"'" ha vo taken ~at e,,", wi:h an I~x\l and illU>tnltioos in book. ".".t'll ""n """.r be comple'ely avoided. Th" publisher lfId tho author no [jability. ""anll... oflepl booi •• fo< any damap ",.ulling from the use of the pmlil'V".rrunll .xamples.
""".-pi
The aulhor at>d publi.her are ah.",YJ valefu! 10 bear your "'SJIODSO> 10 th~ conlen'" of me book. PubHcij CorporolC PubliMrina: P.O. IJ.ox 32<1 0 _91030 Eriangen E_mail ' publ io;hin g -bools@publioi •. de Inl.""", www.p ub lici• .delbooh
ISBN 978-3-89578-297-8 4th edItion. 2008 Ed itOr. Si.m .... "-klkngcselbchaft. Berlin and \h"llch l'ubli,h..-: I'ubIkil COIJl'O'"'lle Publi.hiog, Erla/li"" C 2008 by Publici. KommunihtionsAIClIturGmbll. OWA. ErI""lIen Thi. publiclloon and all parts tlterwf an: plttl«"'" by copyrillht. All rights ..,..,."ed Any ux of;1 outoide the striet prm.-;.ions of the copyrigbtl.'" without th., consetll oftht publisher is forbtddon and ..·m incur pt;nallia. This &pplil!1 pankularly 10 ",prot.!l,ICIion. ..... <1!I&tKm. mkmfilmillj or otbcrproc:ouin3. and 10 6t""'Je or proces.injl: in electlttoic. 1}'1ttm. It al", oppli •• 10 tho use of ex"""'", from til<: text. Prinled in Gcmuny
Preface
Preface
The SIMATTC automation sys,em uni,es aJl the subsystem, of an automation solu.ion under unifonn system architecture into a homogeneous whole from the field level right up to process controL This TotaHy Integrated Automa_ tion (TIA) concept pennits integrated ~onfil!ur ing, programming, data management and com_ mun ications within the complete automation system Fine-tuned communications mechan isms permit hamloniou. interaction \xr.vcen programmable controllers. visualization systems and d istributed lfOs. As the basic tool for SIMATlC, STEP 7 handles the par~onth~sis function for Totally Integrated Automation. STEP 7 is used to carry out the configuralion and progranulllng of the SIMATIC 57, SIMATTC C7 and SIMATIC WinAC automation systcms. Microsoft \Vindow. has been .el""ted as the operating system. thus opening up .he world of standard PCs with the user desktop widely used in the office environment. For block programming STEP 7 provides programming languages that comply with DL" EN 6 .1131 _3: STL (statement list; an Assembler· like language), LAD (ladder logic; a Tepresentation .imi lar to relay logic di agrams), FUD (fun ction block diagram) and the S7_SCL opt ional package (snucrured control language . a Pascal-like high-level language). Several optiona l packages supplemcf'llthese languages: S7-GRAPH (sequential control). S7.HiGraph (programming wi,h state-transition diagrams) and CFC (conn~ting blocks; similar to func tion b l""k diagram) . The various methods of representation allow evcry uSCr to select the suitable control fUnclion description. Th is
broad adaplabihty in representing th~ control task \0 be solved significantly simplifies working with STEP 7 This book describes thc LAD and FBD programming languages for S7 -300/400, As a valuable s"pplement to the language description. and foilowing an introdnction to the 57300/4 00 automation system, il provides valuable and practice-oriented information on the b asic handling of STEP 7 for the configuration of StMATIe PLCs, their networking and programming, The description ofthc "basic fune· tions" of a binary control, such as e.g. logic opcI1llions or storage functions, is panicularly useful for kginncrs or those convening from contactor controls to STEP 7. The digital functions explain how digital values are combined; for example, bask calculations, comparisons or data type conversion. The book shows how you can control the program processing (program flow) with LAD and FBD and design structured programs. In addi tion to the cyclically proce..ed main progrom, you can also incorpor-lle event·driven program sections as well as influence the behavior oftbe controller at startup and in the event of errors! faults. The book ~onclud~s with a general over· view of Ihe system functions and the function sel for LAD and FBD. The COnlcnrs of Ihis book describe Version 5 .4 Service Pack 3 ofthe STEP 7 programming software.
Erlangen, May 2008 Hans Berger
,
The Contents of the Book at a Glance
Overview of the S 7-300/400 progmnunable logic controller
Introdncdoll
1 SlJ\L\TIC S7-3IJGI4Q(l C"",,.,,Uor
I'LC functions comparahle to a comactor control sy,tem
I
Ba.k fun<."I1"ns
Handling numhcN and digi\al operands
I
Digita l fUllctioUJ
4 BI ... ,), Lo~k Operation.
9 Cump.ri..,n Function.
A.>.iD, OR.nd fxdus;ve OR FUDell"".;
Comporjwn Accordu'i 10 Da'" Types INT, DiNT and
Pru~rammabtc
Structure of the Pmgrammahk Oll\lmll .. (H",dware Componellts of$7_300(400);
N""ting t'uru:lions
Memory Ar"",~ Distributed [10
(PROFIfIUS QP):
5 Memory Functio ns
A;,ign. Sci ODd }l.eset.;
Cooununiu>
Midlme o.,lp"a;
M.-.Juie Addru8C.;
bdge e,-.Iua"oo:
Add,."..,., A,,,,,,
I:.~.tnple
of a Cooveyor Bolt
Control SY"t
2 ST EP 7 SGR... r. ~:
Loot! aoo Trunsfer Functions:
C<)ftfiguring tbe Net""orli:;
Sy,t= Functions for Data Transfer
3 SI:\-tl\TIC S7 Pm~m
7 'f!moro Start SIMATIC Timon with F ive Diffe",nt Ch.,-aotrn.tic., Re ~tting and Scannmg; lEC Timer Function.
14 Word Lo~i< l'r<:>o;:e;sin& • AND, OR and &d""i,'. OR Worrl Logi<: Operation
I
,
The Programming Examples at a Glance
The: pre5CIlt book provides many figureS repre~t iDg the use ofl/lc LAD aod reo J'!TOiI1UIIming languages. All programmini examples can be downloaded from the publisller', website _w.publicis.deIbooks. There are NoD Iibruiet LAD_ lJ.ook Md FOD_Book.
The libraries LAD_Book and FBD_Book contain dght programs that are ...entillly illustration, of the graphi~al rcprestntation. Two extens;,·c cxamples oIIow the propamming of funcrion$, function blocks and local instances (Con'·cyor Example) and the handling of data (Message Frame Example). All the uamplcs contain symbols and comments.
,
, ~· 8
fa
and Looalln'to"" ...
103
106 FB 101 fB lOS
Fe 4-t
•
The libraries are supplied in archived fOITII. Before you ean sum working with them, you must dearehive the libraries. Select the FlLE_ DEARCUJVE menu item in the SIMATIC Manager and follow the instructions (see also the REA DME.TXT within the down load files).
To uy the programs out. set up a project corresponding 10 your hardware configuration and then copy the program. incl uding the symbol table from the library 10 the project. Now you can call the example programs, adapt them for your own purposes aud tcstthem onlin e.
.
Llbran fBD Book
DUI1)'pu EXlmples of Definition and Applieatillll
Program Processl n!: Ex.mples or SFC Calli
fB 101 Elmlentary Data Typt' fB 102 Complex Data Types Fn 103 Panomcler Types
fB FB FB FB
Basic FunctiOn! FUD Reprcs<:nlOlion Examples
Conwyor Enml'l e Examples ufBasic Functions and Locallnstanc~
UD151 Data Suucture For tltc Frame HelKkr OUT ~ 2 Data SlIUCture for I Message Fa SI Genc-rale Message Frame FBll Sto~ M~ge Frame FC 51 Tirne-of-day Check Fe 52 Copy Data A~a witb indirt\:t A dd~ss ing Gc n c r~1 [umplcs
Th is double page shows the basic proccdure for using the STEP 7 programming softv.1lI"e.
In the nexi steps. you configure the hardware and, if applicable. the communications conne<:tions. Following this, you creale and test the program.
=w-
L
A utomati ng "jth STE P 7
Start the SIMATIC Manager ami set up a new proj ect or Op"n an cx isting proj ect. All the data for an automation task are stored in the fonn of objects in a project. Whcn you set up a project. yOll create conta iners for the accumulated data by set_ ting up the required s/alions with at least the CPUs; then the containcTll for the user programs arc also created. Vou can also create a program container d irect in the projttt.
°i"",7~
~
'"
Cooflgu ra central rack (select paw-er supply
Use pmject ass istant
a nd CPU)
~"
Creat.. Pruj..ct
CPU MIh DP ma$ter:
contain",
al~~~rt PROf' I6US
CD
, ,,
tnunstaUOrt
1-
-,
Conf'llU'" expansiofl rack (proceed 8 S for central
Open Hardware cbj&e1
"~I
The order for crealing the aUlo_ malion data is not fixed. Only
lhe following general regula_ lion applies: if you want 10 process object s (data), they must exist; i f YOll want to insen object,. the relevrutl containers must he available.
.'
+
proje ct
~",.
rack and CPU Mark DP m a~t?: I
You can iotcmtpl processing in a projC\:t at any time and continue again from any locatinn the next lime you stan the SIMATI C Manager.
Sa~ e
insert a ootMr ttatiot1
is ""I up
I
I
COOfogUf6 000111 .... s tation
CD Project structu re
and canpi le
Compiled configuration data ere located In 11>8 object
Sy~
DB/a
'"
e
Automaling wi,h STE P 7
,
...
...
:::~~
~
u"••
u " . ' p~r"m
:f Slart netwo
Insert miss;"" objects
commun ica~o ns
Compiete symbol tab le
••
•
Incr~~nt81
!
t
"
'::;'~
J Define data structur.. program structure
P"",ram UDTs afld gk>bal DBs Program FCslFBs, ge""rat.. inUance DBs
I
Se leCllllodule with "connection capability" and conllgure connections with t~" connection table
Program
1 I I
~
Single slep
,=1 !
Conf'gure " Iobal data communicalions
, ,
08~
J p il6 program source fi les
I,
.-
(j)
Creato program source ~ Ies
De~n"
,
M'
1
•
,
,
load s)'$tem data
SOU'C
.! P",ameterlze CP modu les ro lovam Isof(v;.....
fJJ
Switch onl;ne
Gan era!" rnf...-&nco d ata
~ . COfTact e'rors , updata offlin .. database
j Test n,,~t ;
(j)
Compiled connecti<>n data are Inserted In the object System Dale
C ompile
Teste
"
Cont<111<1
Contents
:Jnmidvctl(ln . • . • . • • • •
•
S IMATIC S7-31111/41111
1.1
Stru~IUn.:
1. 1.1 1. 1.2 1.1 .3 1.1.4
I.I.S 1.1.6
"
......
rro~nmm"ble Controll~r.
of the Programmable ContruU.,. . . Componenu. S7-300Station. S7..400 Stati"". fault-tolerant SThfAllC. Safely-n:Ltted SIMATTC. CPU M~mory Arcas. Distributed 110 .
'" 20
2.2.1 2.2 .2
" 28
2.2.3 1 .2 .4
Creating Projecu . Managing. Reorgan;~ing and Ar-chiving . l>roj ect Versions C!"""in g and editing tnullipr()je~t~
the Network View. Confi guring a Distributed L10 with the Network Cunfigurntion . Configuring Connections . .. Gateways loading the Conne<:lian Oata Mntchin g Project.;n 3 MultiproJCCt ....
2.5
Creating the S7 I'rogmn .
2.5.1 2.5.2 2.5.3 2.5.4
Introduction. Symbol Table . Pro);I"3ffi Editor. Rewiring Addre.• s I'riOOty Refel"l:!l<:c Data . l.no:uage Setting .
2.S.5 2 .5.6 2.5.7
"" '"
68
'"
70
70 71
" "
76 77
79
Contents
2.'
Online
2.6.1 2.6.2 2.6.3 2.6.4 2.6.5
Connecting a PLC Prote<:ting the User Program CPU Information . Loading the User Program into the CPU Block Handling
2.7
Testing the Program
2.7.1 27.2 27.3
Diagnosing the Hardware Detcnnining the Cause of a STOP Monitoring a nd Modif)'ing Variabl es . Forcing Variables Enabling Peripberal Outputs. Test and process operation. LADffBD Program Status. Mon itoring and Modify;ng Data Addresses
2.7.4 2.7.5 2.7.6 2.7.7 2.7.8
,
Mo d~
.
3'
Progn.m Process ing .
31.1 3.1.2 3. \.3
Program Proccss ing Methods Priority Classes Spe<:ifications for Program Processing Block s
Open ing Blocks Block Window . Overview Window. Programming Networks . Addressing. Editing LAD Elements. Editing FBD Elements.
3A
Programm ing Dma Blocks .
3.4.1 3.4 .2 3.4.3
C!"<'ating Data Blocks Types of Data Blocks Block Windows and Views
80
"
Variables, Constant, and Data Types
3.5.1
General Remarks Concerni ng Variables .. Addressing Variables. Overview of Data Type. Elementary Data Types . Complex Data Types Parameter Types User Data Types.
3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7
" 6 '16
'" '" '" ,n
120
>28
86 87 88 90 90 90
"
" "
Basic F llnctions • . • . • . . . .
D'
Binary Logic Ope rMlon .
'" '"
,
,., 4.1.1 4 .1 .2 4 .1.3 4.1. 4 4.1.5
Series and Parallel Circnits (LAD) NO Contact and NC Contact Series Circuits. Parallel Cire"its. Comb inations of Binary Logic Operations. Negating the Result of the Logie Op~ra\ion
.. . .
94 95
4.2
Binary Logi c Operations (FBD)
4.2 .1
"98
4.2.2
Elementary Binary Logic Operations .. Combinations of Bina ry Logic Operat ions. Negating the Result of the Logic Operation .
99
'"
4.2.3
4.3
'"' , "" '" ,., '" '"
5. I I
.08
5.1.2
'08
5.1.3
.09
'" 112
'" '" '" '"
,.,
Taking Account of the Sensor Type-. M emory Function s. LAD Coils . Single Coi l Set and Reset Coil. Memory Box f BD Boxes.
'"
D2 D2
U3
'" '" 03 ' 038
' 39
'"
'" '"
'42
'" ,44
'" '" ' 48
5.2.1 5.2.2 5.2.3
Assign .. Set and Reset Box . Memory Box
' .3
Midline Outputs.
' 50
5.3. 1 5 3.2
Midline Outputs in LAD Midline OutputS in FBD
' 50
"8
'" U
Contents
'A
Edge Evaluation . . . . . . . .
S.4.1 S.4.2 5.4.3
How Edge Evaluation Worb Edge EVlIlu.o.Tion in LAD Edge EvaluaTion in fBD .
6 .3. 1 ANY Pointer . . . . 6.3.2 Copy Dala Area . 6.3.3 UninlemJptibte Copyi ns of a Duta A~a .. 6.3.4 Fill Data Area . . . 6.3.S Rcading from load Memory 6.3.6 Writing into Load Memory
7 7. '
Thnrn . • • . . . . . .
7.1.1
Gclk."T1IllleprescnllUion of a Timer. . . Staning a Timer . Specifying the Duration of Time RCS<:ltinll A Timet. . Cheding a Timer . Sequence of Timer Operations Timer Box in a Rung (LAO) Timer IJ.m< in B Logic Cin.:uiT
Progrll.mm ing" Counler Seuing and ResellinJ; Counters.
'"'' 85
CounTing
IS'
Checking a Counler.
'"
'" ".. , '" '" '"
16' 16'
'62 '62
163
R.2 8.3 8A
.
186 8S1 Up Counter SFO 0 cru 187 8.5.2 Down Counter SfB I CTD. '"7 8.5.3 Upldown Counter SF8 2 eni D . 187 Part;; Counter Eltampl\! . '.6 18. 8.'
IEC Counl
'64 '65 '65
166 166 166 168 168 17' 170
ott)lal .' uoclions .. .•. ..
'"
,
Comparlsoo
"
Process ing a Comp"ri.f<)n function .....
'93
!J.2
Description of the Compllri:SOll Functions . . . . . . . .
'93
Arlt hmetir
' 97
"
10.1
Pnxe~.iog
f unction
Fn n~ltons
19'
Fu n~tl on ••
an AriThmetic
.....
.. . .
"7
'"
10.2
CalculaTing with Dala Type Jr.'T .
170
10.3
Calculating wilb Oata Type Dt"T 200
'71
10.4
CalculaTing with Dala Type REAL.
'" '"
173
II
Mathern.lleul Funcll(mt
11.1
Proc essing 8 Mathematical function
'00
'"
Pul., Timer .
'" '" '" m
EltteT1ded Pulse Timer .
'76
,\liscdlaneollli Matbmlatlcal functions . . .
On-Delay Tim.....
177
Con version }'unctlon •.
'''' 207
Rclcnli\"e On-Delay Timer
'78
Off. Delay Timer . . . .
'"
Procrssing a COO"ersiOD function
. 207
(FU D) ..
7.' 7.3 7.' 7.5 7.6
'"
7.7
11.2
Trigonometric Functions .•
11.3
Arc
11.4
"
12. \
FUIIClioDs. . . . . . . .
20' 21)'
''''
Contents
Conversion of [NT and DrNT Numbe rs
209
12.3
Conversion of BCD Numbers
2 10
12.4
Conversion of REAL Numbers
210
12.5
Miscellaneous Conversion Functions ..
m
D
Shift Funcdons
'"
Processing 8 Shift Function
m m
13 .2
Shift
2 15
13.3
Rotate
2 16
"
Word Logic
12.2
. .. ... .
14. I
Processing a Word Logic Operation.
14.2
Descr iption of the \Vord Logic Opt:rmions
Program Flow Control
'" '" m 220
18. I
Block Functions for Code Blocks
I 8. I I 18.1.2 18.1.3 IS. I .4 IS .l.5 18 .1.1;
B lock Calls' General Call Box. CALL CoiL'Box. B lock End Function. Temporary Local DOlO Sialic Local DOlO
DO DO 238
18.2
Block Functions for Data B locks
2"
18.2. I 18.2.2 18.2.3 18.2 .4
Two Data Block Regislers 2" Accessing Data Operands . Opening a Data Block Special Points in Data Addressj ng
18.3
System Functions for Data Blocks .
Status Bits . . • .
15.1
Descrip!ion of the Slat", Bits
'" "
15.2
Sening ' he S!aIUS BilS
222
15.3
Evaluating the Statu, Bi!,
224
15.4
Using the Binary Result
225
225 15.4. I Scuing !ne Binary Result BR 15.4.2 Main Rung, EN/EKO Mecbanism 225 15.4.3 ENO in the Case of User_wriuen Blocks . 226
"
Jump F unction • .
16.1
Processing a Jump Func!ion .
m m
16.2
Unconditional Jump
228
16.3
JumpifRLO - ··I".
229
16.4
Jump ifRLO - "O".
229
"
Ma.ter Control
17. 1
MeR Dependency .
17.2
MCR Area
17 .3
MCR Zone.
'"
17.4
Selling an d ReSClling lIO Bits .
233
R~la y
m m 232
239 2<0 241
'" '"'" 2"
18.J.I Creating a Data Block in Work Memory . 18.3.2 Crcaling a Data Block in Load Memory . 18.3.3 Deleting a Data Block. 18.3.4 Testing a Dala Block
"
221
'" m
"
Block Fun ction • . • . . . . . •
\ 9.1
249
2>0
'"'"
m m m m
Block P a rameters . B lock Parameters in General
19 LI Defining the Block Parameters . 19.1.2 Processing the Block l'aramcK"" 19.1.3 Declaration of the Block
253
Paramelcrs
19.1.4 Declaration oftne Function Value 19.1.5 Initializing Block Par"",eters. 19.2
Formal Parameters
'" '"
19.3
Actual Parameters .
2S3
19.4
"Forwarding" B l
260
19.5
F~amplcs
260
19.5 I Conveyor Be l, Example. 19.5 .2 PariS Counter Example 19.5.3 Fe~ E~ample
m
260 26' 262
Program Processing .•
.269
Main Program.
'" 23O
"
20.
Program Organization.
20.1.1 Program Strucrnre. 20.1.2 l'rogram Organi~.ation.
270
'" "
20.2
Scan Cycle Control
272
20.7
20.2.1 l'roccss IllliIge Up
272
20.2 .4 Re.
176 276
20.7.1 f~ndan1entals. 20.7.2 1\>.·o-Way Data Exchange . 20,i.3 Onc-W.yD"tanchange. 20.7,.1 Tnmsfcning Print Dahl. 20.7.S Control f unttiollll. . . 20.7.6 _\Ionitoring runctions .
20.3
Program f unctioos
m
20.8
20.3.1 20.3.2 20.3.3 20.304 20 .3.S 20.3.6 20.3.7
Tillie or dsy . Read Sy'tem Cl"",k Run-Time Metcr , . Compressing CPU Memory , Waiting and Stapping . . . Multiprocessing MOlle . . . . Determinin& the Oil Program Runtime. .. . . . . . . . Ct.angin8 program protK1ion .
27K
20.8,1 Basks , . . . 20.8.2 Estah lishing and cleari ~ s down Co""ect ion~. . . , , 20.8.3 nata transfcr with TCP "flliv~ or IS(}...-,n-TCI' .... ,' 20.8 .4 Dato. transfer with UDP. •
20.3.~
2004
Cmnmunication via Distributed I/O
20.4.1 Addressing PROFI BUS DI'. 20.4.2 Confi~lIrin g I'ROFlBlJS Of' 2004.3 Special F'unct'oru; for PROI'IRIJS 0 1' . . . . . . 20.4,.1 Addres
20.S
27S
2RO
no 282 2K2 2M2 283 286 287 287
292
'" 3" 300
1/0 .
314
Global Dma C<.>mmun; catiw .
320
20 .5.1 Furtdamemalll . . . . . . 20 .S.2 Configuring G O communication 20 .5.3 Syslcm Functions for GO Communicotion. 20.6
274
S7
l:J"si~
Commuuicatioll .
320 322 324 324
20.6. 1 Sla\ion -lnternal S7 BAJic Communication 314 20.6.2 Sys\CItl Funcf;Oru; for Slation-internal 57 3 .... ie Commuruealioll . 325 20 .6.3 Slahon- Extcmal S7 FllSic 327 Commnnication .. .. , 20 .6.4 System Funcf;on~ for Station _Exter_ na l S7 Ra,i o Communication 318
"
20.9
S7 Communication . . .
IE communie,uion ..
DO DO 332
m 335 335
3" 339
no 341 343 345
PIP c"",",unication with S7-300c 346
20.9 .1 fundsmCfltals. 20.9.2 ASCll driver and 3964(R) pro
347 . 349
20 .1 0 Config'Jration in RUN . . .
352
20 .10. 1 I'r..paration of Changes in Con figuration. . . . • 20 .1 0.2 ChangeCnnfiguT'/lti(l
'" 352 353
3S3 3S4 354 354
21
Inlcrru pt H a n dlln K
356
21.1
General Remarks .
356
21 .2
Time-of-Day Inttmtpts .
21.2 .1 Handling Tlme-of·Day Interrupts 358 21.2,2 Configuring Time-of-Day lnt~m,pts with STEP 7 , 359 21.2.3 S~·.tcrn t 'unction! for Tirne"" f-Vay lntcrrupt~, 359 21.3
Proces,ing the Synchronous LYcl~ Interrupts. 370 21 8.2 Isoehrone Updating OfProc~s., Image. 2lX3 Configuration of Sync monous Cydc Interrupts with STEP 7 372
21
~. l
21.9
Handling Interrupl Events
372
21.9. I Di""bling and Enabling inl~rrupts 372 2 1.9 .2 De laying and Enab ling I nl"rrupg 373 21 .9.3 Reading additional Interrupt Infonnation. 374
"
Starr_up
Char~cteri"tks
12.S
Parameterizing Module"
22 .5.1
Gcn~ral remarks on parameICrizing modules. 22,5,2 System Bloch ror Module 'Paramelerizalion 22.5.3 Blocks for Transm illing Data Records
393
23.1
Synchronous Errors.
;93
23 .2
S}"chronous Error Handling
395
23. 2 .1 Error F ilters 23.2 .2 Masking Syn~hronous Errors . 23.23 Unmasking Synchronom Errors 23.2.4 Reading the Error Rcgi,\cr 23.2.5 Entering a Subs\i,u{e Value.
'"
23 .3
AsynehrotlOl1< Errors
398
23.4
SY"em Diagnos!ics.
'00
23,4,1 DiagnoSlie 'Event' and Diagno8{ic Buffer. 23.4.1 Writing User Entries in !he l)iagnosri~ Huff"r . lJ,4,3 Evaluat ing O iagno'tic Interrupt; 23,4,4 ReHding the System Stat"s US{.
22 .1.1 Opera{ing Modes .
376
22.1.2 HOLD Mod~ . 22.1.3 D i,abling the Omput Y.odules . 22.1.4 Re,mn Organization Blocks
377 377 377
23.5 .1 Readin g Oil! \Veh infomlation. 23.5 .] Web information
22.2
378
Remarks
Power_Up
22 .2. I STOP
Mod~
Appendl~
• ••
•
•
•
no
24.1
Block Protection
22.2.4 Retentivity 22.2.5 Restan Parameterizati
m
24.2
Illdirect Addressing.
of R~'tHn
22 .3 1 START-UP Mode 22.32 Cold Re
22.4
Ascenaining a Module Addre.s
•
m
Pointers: General Rem
383
243
380 380 380
m
.
Supplemen{S to Graphk Progrllmmin1: •
378
Typ~,
397
;oJ
;97
400 400 401 403
th~ lV~b S~"ver
22.2.2 Yfemory Resct 2 2 .2.3 Re'toring the fa~!Ory setlings
22 .3
;oJ
Web Server
23.5. 1 Activating
378
379
390
'Error Handling
23.5
G~neml
'88
23
'" 376
22.1
3R6
24.2.1 24. 2.2 24.2,.1 24 .2.4
BrieflJescription of the ·-MessHge Frame Example" .
..
4U(i: .97
'"
"8
'"' .08 408
"0 410
'"
ConteDts
......
'" " m
fun ctio n
16. 1
Bask functions.
26.2
Digital Functions
426
IEC Function Blocks
'"
26.3
Program Flow Control .
'28
25.4
S5·S7 Converting BI
'" 420
25.5
Tl-S7 Converting BI
421
Function Set FIJD .
25.6 2S.7
PID Control BI
27 .1
Basic Functions.
'"
Communication BI
27 .2
Digital Functions.
258
MisceUanwus Blo ch.
'" '" m
"
27 .3
Program Flow Control
25 .9
SIMATIC_NET_CP .
423
Bhxk Librari es . ..
"
25 .1
Organization BI
25.2
System Function Bl
25.3
25 .10 Redundant]O (VI) 25. I I Redundant 10 CGP
'" '"
•
~t
LAD.
'"
", 429
<3, m
Indu .. . . . .
433
Abb re,'lations.
'"
IntTOd uction
Introduction
This ponion ofth~ book provides an o,-erview of the SIMAllC S7 -3()(J/400. The S7-3 00/400 programmable co ntroUer is of modular design. The modules with which it is configured can bc ccnmll (in th~ vicinity of the CPU) or d i times arc the prerequis ite for fa st progrrun processing .
T he fir<;t chapter contains an ovcrview o f the hardware in all S7 -300/4 00 prOb'Tammah lc con· troller. anu the second chapter comains an OVI.-"Tview o r the STEP 7 program mi tlg softwan.: _ The basis for the description is the fun clio n scope tor STEP 7 Ver<;ion 5. 4 SP3 . Chapter 3 «SIMATIC 37 Program" s erves a, an introduction to the most importBnt elem ents "I' an S7 program and shows the programming of individual bloch in the programming lan gunges LAD nnd FBD . The functio ns and operations of LAD and H:lV atc then described in the subs~'qucnt cbapters of the book. All th c description_< arc explained using bric f ~xam ples_
STEP 7 is the programming wftwarc for S7300/400 and the automation tool is the 31,\tATfC Manager. The SIMATlC M an"gcr is an application for the Winnov." op"rating systcnts from Microsoft and contains all fLInetion, need<;"d to set up a project. 'Vhen neces,ary. the SIMATIC Manager ,tan, add itional tool, . for example to configun.: , talion" initia liz~ moduks. and 10 write and tcS! pro gra,,,s,
You ionnuiate your automation solntioo in the STEP 7 I',ogramrmng languages. The SI I\ IATIC S7 program i. structured , that is to say. it cons ists of blocks w ith de fLlled functions that are ~umposed ofnctworks or o lllg". Differe nt priori ty c1as,cs allow a graduated interroptibility Oflhc u.er program currently cxccnt ing _ STEP 7 works w ith variahles of varion, data types starting with binary variables (dam type BOOL) through digital v ariables (e .g . data type TNT or REAL for comp uting tasks) up to complex data type, such as arrays or stmcrure. (~ombinations ofvs riables of different types to form a single v ariable).
,
SIi\lATIC S7_3 00/400 Prol:rammMb lc C o ntruliH Structure of the prognunmab le co ntrolkr; distributed 110; communi cat ions; IDmhde addre"es: operand areas
STEP 7 Pro~~mmlng Sorman STMATIC Manager; processing 'I proj ect : cont,guring a stati on; ~onfiguri"g a nctwork; w riting programs (symbol table. prob'Tdm editor); switching online : testing pro b",'ms
J
STi\J ATT C S7 P rogra m Program processing with priority classes; program blocks: addressing va riables; prob,,-amming blo<:ks with LAD and _FBD; variahles and eon .tams; data types (overview)
SIMATIC S7· 3000'4(IO J>rognmmable ControUer
I
SlMATIC 57-300/400 Programmable Controller
Structu re of Ihe Programmable
1.1
Controller 1.1.1
Compo nen t.
The SfMATIC S7_3001400 is • modular progNlmmable controlieT comprising me following componet"':
> Racks AcootnlllOdate the modules and oonnect them to each other ~
~
1.1.2
Central proce$,ing unit (CPU) St~ and pr""e..." the USef progrnm
Centnllzcd configuration
Interra"" modules (L"-1s); Connect the- TIIcki 10 ODe another
I>
Signal modul~ (S'-1s); Adapt the 'ignals from the system 10 the internal signalleve1 or control actuators ... ia digital and analoa: sianals
> Function modules (FMs); E~ecutc
complex or time-en tical processes illdq>end01ltJy of the CPU Communication. p~ (CPs) Establi.h the oonn~ion to subsidiary n<"I_
worb
(.ubnCI~)
> Subnna Connecl programmable conlroller5 to eacb other or to other dcviccJ A programmable controller (or station) may com;stofseveral racks. whkh are linked toone another via bm cable,. The pOwer sU;lply. CPU and VO modules (5\-1,. FMs a&d CPs) are pluaac:d into me central rack. If th= is not enough room in the cenlnl! rack for the LO modul"" Of if you ,,"ant some or 111 1,0 mod.lIes to be 5CJHIrate from the ccnlTlll reck. expansion rach are .... ailable which Ire Connecl<:d 10 the centro l rack via interface module!< (Figure l.l).
20
The .... cks connc<:t ll>e modules with two buses: the 110 bus (or P btu) and the communication bUI (or K bu.). The liO bus is designed for high-spi:cd ex change c>f input and output signals. 1M comrnUniClltion bUi for the exchange of l"lie amounts of data. The communication bll$ conne<:\!j the CPU and the programming de"'lce interface (MPI) with function modu les and communications prt>ccNOB.
Power supply (PS); Provide!< me internal supply vollag~s
t>
t>
It II . Iso possible 1000nn~ di,mibuted 1/0 to a l!anon (Ie<: Chapter 1.2.1 ··PROFlBIJS OF·).
57·300 Statlnn
In an 57.300 controller. I.! many as 8110 mod· ules can be pluggffi in lO the central rack.. Should this slllg.le-tier configuraltOll prove in,ufficinll. you ha,·., rv.·o opIiOlls for control· lers equipped with a CPU 3D or higher. tv,o-tier configuration (wilh 1M 365 up to I meter l>etween rad,s) or
I>
,\
~
A configuration of up to four tiers (with 1M 360 and Lvi J61 up to 10 mctm between TIIcb)
You can <>pc:nIte a maximum of 8 modules in a TIIck. TM Dumherofmodules maybe: limited by the maximam permissible c = t per rack.. whIch is 1.2 A. The modules all' linked to one anOther ... ia a backplane bm. which combines the fUDctiuns of the P and K buses . lura l bUl u\l,menl A special feature regardina: configuration is the uSC of the FM 356 application module. An 1':>.1 356 IS able to ··split~ a module·s backplane bu< and to tllte o\"er control of the- remaining mO(\. ules in the split-off'"local bus legmen'" it""lf. The limilll!;oO$ mentioned ,beve regarding the
I. I Struct ure of the Prugrammable Controller
Modular configuration
Four-tier contigural;on wilh 1M 3()ti ""d [~j 361
of aD S7-300 Stati"n
Two-t i. , ,,,,,f'gur.non WI'" l.\t 3M
Modul a r con fiaura tion of aD S7-JOO . tation ], ' ... "",,,I CQO.wli« ,,,,,~ . N 460- 1
w_
1.\1 %()'l 1.\1 <60-<
1:-.< .{,l·l
Loc. l "'1llI" up'u 5m witt""" ~ V tr:.rwniMiOIl (l\t46 j-{))
R omot<; ",ng<
"PlO 100m witboul 5 V
.... ''
Romot< rang. up (oWO m ""I00U' ~ V
'Oln.m i" ion (1M 461 ·4)
R """". rangefur up 10 WO tll
S5 oxpan>ion uni" (IM 314)
F ; ~u",
1.1 Iiordware Conillt(uMion for S7· ]()()/ 400
Loco! r>
5V
"""""',>Coo
(N 46\ · 1)
I Sn.tATIC S1_300/400 Pro&rvmmabk ControUII'f
number of modules and the )lOwer consumption ~I!
The now dis<:omin ued CPU ) 18 can be replaced by the CPU, 3 17 and 319,
packUIIC that is inlegrated in the SIMATIC MaMb'l:T afu:r installation. The Technology Cl'U . have u I'ROFIBU S DP i(1tcrface that allow. opcrutioll liS DP master or DP sla,·c_ The Ll'U. an: uJed fur Cf(>M-SCCIOT IIUlomation tasks in series mcch~nical equipment manufacrure. special medtanical equipment manuf....1urc. and planl building. F.nu(~
Cl'U5
The CPUs 3xxF an: u,;ed in production plant. with increa,ed safety requirements. The relevu,ut PROF lBliS and PROflNET interfaces al · low the QPC11I{;On of s.al~ty_related distributcd Ii o u~in.a the PROFhiafe bus profile (see "S7 0151ribu[(:d SafC1y~ under 1.I.S ~Safety-related SIMATle'). Standard modules for normal apphcalion' can be uxd parallel to safety-"'Iated ~ration ..
SIPLUS S7_300
The SIPLUS product family offcfti CPU, and module, based on the S7-300 tha' can be use d environmenlS. With hori~.ont~1 iostallalion, you have lID extended tem~rarure range of _lSoC to~, lncy ha"e inc",a.ed immunity 10 vibration and shock. and they JT>«I the incrc:a.ck ~. til harsh
Compllet CPU.
'''e )"-" C CPU. permit C<>IISIJUcuon of com·
pact mini programmable CUDlrOIlLT>. Ikperlding on me vcr;ion. they alrtady contain: ~
I>
In\cgral liOs Digital and analofl inputs/outputS Integral technoi
Counting. mCaliurcmCIl1, control. po,itiooing I>
Integnol communic~lions in'crfaccs PROF1BljS OF masU:T Of slave, poim·;.,.. point coupling (PIP)
Thc technological function.s u.rc ~)">tem block.! which use the onbo..rd 110 oflhe CPU. T~~hnology
CP Us
Tbc C PUs }xxT combiM open_loop c01ltrol fU[IC'\ioru; ",-im muple motion control function,. The open_loop control component i, dcsigned ai in a standard CPU. 11 IS o;Q(Ifiilln:d, parametcri~ nnd progr.1mmed \I~mg STEP 7_ The technology objects and th~ IlIOtion conlrOl com· pooncnt require the oplional 57-Technology
1.\ .3
S7-400 Sta lion
Ctnrrallzed eonlieunli()n The conlrOiler me\( for the S7-400 i$ available in the \...· Rl (18 slots), U R2 (9 stol~) aod CR3 (4 sh)ts) vcrnions. UR I and UR2 can al.o be used as expansion r~cb_ The power supply and the CPU a lo;O occupy slots in !he rack<. possihly evm tWo or more per module. If necess.ary. the number of slots available CM ~ inc",ascd usina e~J'ans;on "",ks: L"'R I and cR I ha"e 18 s\o!$ each, UR2 and ER2 have 9 ta.eh. The 1M 460-1 and 1M 461-1 in!erf.cc modules m~e it pmsible 10 haveonc exPMlion rack ptr
I I Stnlcture oflhe Programmable Conlroller
intcrface up to I.~ meters from the cenlral rack. including the 5 V "'pply voltage. In addition . a, many a, four expansion racks Can be operated up to 5 meters away u.ing 1,,1 460-0 and I~ 41i1_0 interface modules . And fL nally, 1M 46O .} Bnd 1M 461·} or 1M 460-4 and 41i1_4 interface modules can be used to operate many a, four expansion racks at a distance of up to 100 or 600 meters away.
a.
A maximum of21 expansion racks can be con nected to II central ra~k. To distinguish bem'een racks. you set th~ number of the rack On the coding switch of the receiving 1M. The backplane bus consists of II para1lel P bus and a serial K bus. Expansion racb ERI and ERl arc de,'igncd for ",imple'" signal modu les which generate no hardware interrupts. do not have to be supplied with 24 V voltage via the P bus, require no back-up voltage. and have no K bus connection. The K bus is in racks URI. UR2 and CRl either when these rackS are used as central racks or expansion rach with the numbers I to 6. Segmented rack A s!",cial feature is the segtn""ted rack CR2. The rack can accommodate m'o CPU, with a sh"",d power supply while keeping them functionally separate . The t",o CPUs ~an =change data with one another v ia the K bus. but have completely separate P buses for their own signal modules. 1\1ultiproccssor mode
In an S7_400, as many as four speCIally designed CPUs in a suitable rack can take part in multiprocessor mode. Each module in this station is assigl1ed to only one CPU, both with its address and its interrupts. See Chapters 20.3 .6 "Multiprocessing Mode"' and 21.7 "'.\1ultiproce5sor Interrupt"' for more details. Connecting SlftlATIC SS module. The 1M 463 -2 interface module allows you to connect 55 expansion unit' (EG 183U. EG 185U. EG 186U as well as ER 701·2 and ER 701-3) to an S7-400. and also allow, ~ emral ized expan.,ion of the expans ion units. An 1M 314;n the S5 expansion unit hand les the link .
You can op~rate all analog and digital modules a llowed in these expansion units. An S7-400 can accommodate as many as four 1M 463 -2 interface modules: as many as four S5 expansion units can be con n~cted in a distributed configuration to each of an 1M 463·2'8 two interface,.
1.1..1
Fault_tolerant SnlATIC
Two des igns of SlIvtATIC S7 fault-tolerant automation systems are avai lable for applications with high fault tolcrance d~mands for machines and processes: ,ofh-vare redundancy ,md 57·400HlFH. Software redundancy Us ing SIMATTC S7-3001400 standard components. you can establi,h a software-based redundam system with a master station controlling the process and a standby Slation asswning comrol in the event of the maSter failing. fa u lt tolerance through software redundancy i, suitable for slow processes because transfer to the standby station can require several second s Mpending on the configuration of the program mable controllers. The process signals are "fro· ~en"' during this lime . The slandby stalion then continues opcr~tion with the data last valid in the master stati on. Red undancy of the input/oulput modules is implemented with distributed VO (ETIOOM w ith L\1 153·} interface module for redundant PROFlBUS DP). Tbe optional "Software Redun dancy" software is available for configuring. fault -tolerant SIMATIC S7-400H The SIMATIC S7-400H is a fa"lt-tok""'t programmable controller with redundant contiguration comprising two central rack!!, each w ith an 11 CPU and a synchronizmion module for data comparison via fiber oplic eablc. Both controllers operate in "hot standby" mode; in the event of a fault. the intacl controller assumeS o!",ration a lone via automalic bumpless tTanskr. The U R2-H mounting rack with 1\\'0 times nine s lots makes it possible to establish a fault -tolerant ,ystem in a single mOllnting rack.
I SIMATIC S7_.;OO/400 Programmable Ccmtroller
The 110 can have normal availability (singlecharmel, single- sided configuration) or enhanced ava ilabil ity (single--channd .witched eontiguration with ET200M). Communication is ~arried out over a simple or a redundant b"s. The user program is the same as that fo r a nonredundant COI)(roller; the redundancy function i, handled e"elu ,ively by the hardware and is invisible to the user. The ,oftware package required for configuralion is indu ded in STEP 7 VS .3 and laler. The siandard library Red",,dUtll fa already supplied contains bloch for supporting lh" redundant 110.
l.l .S
Safely-related SIMATIC
Failsafe automat ion systems control proce"es in which the saie state can be achieved by dire<;t swi tching off. They arc u! transmi",ion of the user data of safety functions with in the standard data ttlegram . SlMA.TTC S7 provide, two systems for implemelllation of "Safety In'egrated" ; S7 D is tributed Safety and S7 FIFH Systems . 87 Distributed Safety S7 f)istrihuted Safety is a failsafe autorruotion system mainly for appl ications with mach ine controls (for protect ion of mach ine. Hnd personnel ) and in the process industry.
F_CPUs cUlTently available arc the CPUs 315F2DP and 3 17f-2D P for S7-300, the CP U 41 1iF2 for S7-4OO, and the basic muduk IMI5 1- FI CPU for ET2ooS. The F·modul e. and f-sub· modules are connected to S7-400 u.ing PROI'! · B US DP with the safety_relevant profile PROFlSafe . U,e o f F- modules in the controller rack is additionally possible w ith S7-300. STEP 7 w ith th e optional S7 Distributed Safety package is necessary fo r configuration and progranuning of the failsafe system . The safetyrelevam scction of the program is programmed u,ing F_LAD or F-PBD with a limited operation set and fewer data types oomparcd to the basi c lan guages. If a fault is dete<:tcd in the ""fety program, the F-CPU eme", the operating ,tate STOP. The option package also contain , a block library fo r the safety program with failsafe blocks and templatc •. S7 F/FH Systems S7 Fff H Systems is a failsafe automation sys· tem ba.ed on S7_400 with main applications in th . process industry. S7 F/FH Systems is based on the S7_400 automation system . The F-modules and F-submodu les arcc conne<;ted to S 7·400 using PROI'TBUS DP and the safety- relevant profile PROFISate. With S7-400F, a failsafe uWr program can be i n~orporated into the standard Uscr program . Tn addition to failsate ty. tl><: S7-400FH also provides increas.d availabil ity. If a Mtected f"ui( results in " STOP of the master CPU, a switch is made w ith(mt feedback to the CPU running \tl hot standby mode (""c ].1.4 " Fault-to ler",,! SIMATlC"). Con fLguration is carried out using the standard applications of STEP 7, V5 .1 and later. The option package '·S7 F Systems" is required for paramctcrL,ation of the failsafe signal modules and for programming o f the ""fety·relevant program components, p lus Ih <: option package "eFC", VS.O SP3 and later. thc option package . $7 -SCL" V 5.0 and later and - for the fa ult-tolemnt funclion, the option package "S7 H System," V5 .1 and later. Spc~ial
library
f unction blocks from the supplied Fbe called and interconnected using
~
I. I Structure of the Programmable Controll~'r
efC (Continuous Function Chan). In addit ion to functions for pro.:rmnming safety functioru. they abo contain functions for Crror d.le<;tion and re'ronse . In the event of faulls and failures. thi. guarantees that !he faihaf. system is hdd in a safe statc or is transfe'TT<:u to a saf~ ,tatc. If a fault is dctcctcd in th c safCIY prograP1. the bilsak ~om""nent of the plan' i< ,witched off, wherca__ the remaining pan cominue, to oper· a'e.
uratioru), and fmther projc~l-specijic d" ta ,uch as symboltahle, and comments.
An f_mntime license must b~ pre,em on each CPU to peTIllit opt''''tion of an S7-400f/fH. fail;afc ,ignal module, (F.modulcs) ar~ r<:q\J ired for ,afety operatio" . and are operated in the ET200M disrribU1~d VO station.
T he cpe s have a slot for a plug-in ",,,mory .,"b"wdu/e. The load memory, or pans thereof. is
"ailsafc 110 1b~ fai lsate signal modul es (F-modules) are require
The F_module, can also he used in standard appl ications with incre"sed diagnostics require· ments . The F-moduk" can ]:x; "Pe--ratcd in redundant mode to incr~ase the availability hoth in standard and ,aferyoperation with 57 Ff FH 'yOlem,. The failsafe 110 is a,·ai lable in vat,om versIOns: .,. The fa ilsafe signal modules of 57 -300 de,ign ar~ us"d in the ET200M distribu1ed VO slalion or ec-ntrally toge'!he--r "ilh lhe CPU 3 15f_2DP >
The fJil",fe power and elc"tronics moo"les arc \J>I'd in the ET2005 distributed liO station. lor whieh the 1:>1 151.FICPU basic module is also available as a f"ibafe CPU.
\>
Fail,afe PROfIBU5 DP standard , I ay~s can also be used with S7 Dimibuted Safet)".
1.1.6
Tne Qnlin~ dafa "o",ist of the mer pwgram and the system data on the C PU, and are ac com mo presenl in addition arc the 'ySlcm memory and """ibly a back up mem"'"y.
Th. 110 moduks contain memories for lhe signal state oIrhe inputs and outpu18.
located hom: (sce " Physical design of CI' U
memory" later). T he memory submodule is dcsigned as a m"",ory card (57-400 CPU,) or a, a micro memorv c,.,-d (S7_300 CPU. and ET 200 CPUs d~rivcd from these) . The finnwarc "f !he CPU operating ,yst~m can also be updated using the memory s"bmodule. i\I. m o~·
card
T he memory module for the S7-4OO CPU. is the memory card (MC). There arc two 'ype' of memory card . RAM eards an d flash EPROM e..,-ds.
IfYl>" want \<) expand load memory only, use a RAM card . A RAM card allows you Il> modify th~ entire user program onlinc. This i. nece,sary, for c,ample, wh~n t~"ting and staning up l arg~r program,. R."l"" memory cards 10""' their conte'll t$ ""e"II unplugged. I t you wan t to prote~1 your user program, includmg configuration data and moouk paramete", against po\<-,,' failure following testing and ,tarting up even without a backup battery, uSC a fla,b. EPROM card . In this ca.,e, load the ~~,ti re program offi incom" the flash EPROM card with the card plugged into the programming device . With th~ ", levant CPUs, you can also load lhe program ""line w ith the memory card plugged into the CPU.
C PU l\-Iem ory Areas
Figure 1.2 shows the m emory area, in the programming device, the CPU and the ' ignal modu les whicl1 are important for )"our program The programming dcviee conMins the offl;ne data . These consist "f'hc usc' program (program code and user data), the syst~m data (e .g. hardware, nen.,.ork and inte rconn~C1ion coniig-
.\licro
m. mo~'
card
T he memory suhmooule for the n.w~"I 57 -300 CPU s i8 a m icm memory card (MMC). The data on the :>fMC are ,aved non-volatile , but c"n he n:ad, writtcn andddeled as w ith a RAM. This re'rome penn it ' dJia backup without a batler),.
I SIMATIC 57-3001400
-....
Hardware
Sym~ .~
P~le
Canlrolkr
System
r -f--ff d.ta t>k>cks I
(contlguration
dataonlinel
+ll<.
Arcnive
r ". compl~t6 proj6cr dllrll can btJ ioadfHj in rhfJ archIVed stat. kim ".,. CPU'~ load """""Y. If """ssaiY. ltMly""" be_lOthe
-
Paru
01".,. hlgllNghred
'""
.,... """ IN PfjratnftIei1z9d In CtIn.In CPUs.
InllRUp!
momc:wy _
PleNa nolO. "".,. _
syslfNn
memotY~.
commotl ph.,.;c.l memotY 1ft
.re•.
1ncre.S& '.Il'. In IhI!
$}'$Iem memo.y rowns
In • redlJClion
TIm ... funclion$
in tI>e
""'" """""
do'*" on _-..d.
ptOgT1ImmIfIf/
.JIe,
FI",,,, U CPU Memnry A"'~.
The complete load memory is p~sent on tile MMG. meaning thlIt an MMC is al""ays requirW ror op=l.1ioo. The MMC can be used IS a portable memory medium for user programs or finn....= upd;!tel. Using special sY'tern functions you C3n ",ad or write data block!; on the MMC from the ~ prognun, for exam_ ple to ,."ad recipes from tile M\fC or 10 create a measured-value arcbive 00 lh~ MMC Bnd to provide it witb data.
I..oMd memo ry The rntm user program. Including configuration data (system dati). is in the load memory. The U ""," program is 11 ...·ay~ Initially transferred from the programmina device 10 the load mem_ ory. a nd from !hcre 10 Ille work mrnlory. The
program in Ihe load memory is not processed as the eootrol program.
If a CPU does not ba~e. micro mo;mory card. the load memory is designed as I memory integnlted in tI:re CPU or as a plua-in memory caro. II ~.n be designed as a RAM or ROM. Ifload mrnlOTY consists of flit inlq.ratcd RAM or " RAl\-1 memory card. a blrckup banery is required in order to 1c.C<.1' the ~cr prognlIIl retrnlh~. Where load memory i~ i1npl~memed .1 intcgnlted EE PROM, as a plug-in flasb EPROM memory card or as • micro memory can!. the CPU ~an be opettled without bancry
backup. From STEP 7 VS.l onwards, lind with appropriately designed CPUs. you Can save the com-
1. I Strucrure of the Programmable Controller
p lete project data as a compressed aRhiv... file in the load memory (sec Chapter 2.2 .2 "Managing, Reorganizing and Archiving"). Work
m~rn ory
Work memory is designed in the fonn of highspeed RAM fully integrated in the CPU. The operating system of the CPU copies the pro_ gram code "relevant to execution"' and the user data into the work memory. "Relevant"' is a characteristic of the existing objects and does not mean lhal a particular code block will necessarily be called and executed . The "'actual"' control program is executed in the work mem-
NY Depending on the product, the work memory can be designed either as 8 corrdaled a~a or divided according to program and data m emOries, where the laner can also be divided into retcutive and non-retentive memories. Whcn uploading the user program into the programming device, tbc blocks arc fetched from the load memory, supplemented by tbe a~tual values of thc data operands from the work memory (further infonnation can be found in Sections 2.6.4 "Loading the User Program into the CPU" and 2.6.5 "Block Handling"'). Sy't~m
memory
System memory contains the addresses (vari_ able s) that you a ~Ces, in your program. The a ddresses Qre combined into arcas (addre ss areas) containing a CPU-specific number of addresses. Addresses may be, for example , inpms used to scan the signal stBtes of mom en_ tary-contact switche, and limit switches, and outpUtS thaI you can use to control contactors and lamps. Tbe system memory on a CPU contain, the following address areas: ". Inputs (I) Inputs are an image ("process image"') of the digital input modules. o
o
Outputs (Q) Outputs are an image ("process image") of the digital output modules . Bit memories (M) Store< ofinfonnation accessible throughout the whole program from any poinL
o Timers (T) Timers arc locations used to implement waiting and monitoring times.
o Counters (Z) Counters are soJhvare-levcllocations, which can be used for up and down counting.
o Temporary local daIS (L) Loc atiODS used as dynatJlic intenncdiate buffers during block processing. Th~ temporsry loca l data are locatccl in the L stack, wh ich the CPU occupies dynamically during program execunon . The lett~'TS enclosed in parentheses ...,present the abbreviations to be used for Ihe d ifferent add...,sses when wriling programs . You may a lso assign a symbol 10 e ach variable and then use the symbol in p lace of the address identifier. The sy.tem memory also contain! buffers for conununieation jobs and system messages (di agnostics buffer) . The sile of these data buffers. as well as thc size of the process image and the L stack, are parameterizable on certain CPUs. Phy.ical de.ign of C PU memory The physi~al de.ign oftbe load m"",ory is d ifferent for the ,"ariou~ types of CPU (F igure 1.3). The CPUs w itb micro memory card do not have an integrated load memory. A micro memory card mu<;t always be inserted to permit operalion. The load memory on the micro m emory card reacts as if it contains RAM and ROM components . The program is transmitted and teSied completely nonnally in the RAM, Bnd then written into the ROM by means ofa menu comma nd following the test. Retentivity of the user program is achieved w ith Ihe micro mcmDry card . With Ihe CPU 3 17. pan of the work memory can be used for retentive data bl ocks. The rest of the work memory (complete memory less ...,tentive data quantity) Can be used for the pro-gram code and the non_retentive data. The integrated RAM load memory with the S7400 CPUs is designed for small programs and for modificalion of individual b locks ifthe load m emory is a flash EPROM memory card. If the complete control program is larger than the
I $IMATIC S7·3OO/400 Programmab le Controller
51 ·300 and ET CPUs without adju stabl a deUt retentiv ity
Micro me
card
iC"'"'-____________--,_______-,Work m emory Program codl> Use< data
l oad mamory RAM and RO M
System memory
I
57·300 and ET CPU. w ith adjustable data ret.ntlvlty Micro "'.,," ca r
,C,'", '--_____________________ Work. mamolY Prog ram code User data
Loadma mory RAM and ROM
Sy"em memory
non-ret&ntive Us-erdata fele~tive
5 7-400 CPU M&m CI'lrd
C'"
Load memory AAM
load memory
RAM
•
I
Load memory FEPROM
Work memory Program code
Systam ..... mory
I
Work memory Use r data
Figu .... \.3 Phy
integrated load memo!)', you require a RA"I memory card for te>t i~g. The test ed progrllm i, then transmitted by the programmi ng device 10 a Tlash EPROM memory card which you insert into the CPU for operalion. The work memory of S7·400 cre, is divided into two pans: one part ,av~' the program code. the other th e user data. Th e system and work memories itt the S7-4OO CPUs constirnte one (physical) unit. If, for example. the jLze of the pfoI'~ss image change,. this has effects 011 the size of the work memory.
DF use, the PROFlliUS imbnctwork for daTa tnm omi,s ion. PROFTNET 10 The Industrial Ethernet subnetwork (for f""he, information, see Chapt~ 1.3,2 "Subnels'J.
1.2.1
PROFIBUS DF
PRO FlBU S Dr provides a standardized interfaee for transferring predominantly binary pro· CO" data b etween an "interface module" in the (c eIltral) progranunabl e conlrol!er and the field devices. This "int"face module" is called The DF maoter and The field devices are the Df
,h,·cs.
1.2
Distrib uted VO
Distri buted VO refers to modules cor.nected via PROFlB US Dr or PROFTNET 10, PROF/RL'S
The DP maSter and all the slaves it control. form a D P maSter system. There can be up 10 32 'lations in one .egmen t and up to 127 stations in the entire nem·ork A DP master can control a number of DP , laveo spec ific to it.el f. You
1.2 Disuibtne
can also connect programming devicu to the I'ROFlBUS DP network as well as. for tumpit. ,Jev;ces tor human machine interface, 1iT200 de\kts or SIMATIC SS DP ,la\",s.
PROFIB US OP is usually opc,.,ucd Q8 a "mono lnllSl~r syslem". thaI is. one Dr mnster conlrols severnl DJ' .I~~e~. Tbe Di' maSter is the on ly tTU<.ter on tbe bus. with Ihe exception of a lemporarily a\"~il .. bk PJUb'nWlIlliny dtvicc (dllanOSI;CS and $("",,;ce device). The DP ma~ler and the Of' slal'e~ L\Silned to il form a DP IlUblc-r system (Figure 1.4). You can al>iQ install several DP mastCT syslrms on one PROFlHUS .uhnel (multi mast .... s~·. tern). Howe' er, IlIi< ine,..,aS("S the ""~iX>nse lime in indIVidual eaoe. hccause when a OP !1U\su,.r has initilllucd "its" or slaves. the access !'igh\.< fall to the " ex t DP masler that in tun, initializes "il ." or .c'~,.,.1 Df' mailer '~Slcm$. In multiprocessor m<>
S7 ".floa "ltb DP ",,".r,
IlP mastu Th~ DP master is the IOCtive node on th~ PROFlBUS n~".vorL It exchanges cyclic data with "11'" OP slaves. A 01' master can be
c>
A CPU wilh int~grnl DP IIlltster interface or plug-in im~rtace submooule (c.g. CPU 31 ~2DP. CPU 4 17)
t>
An interlace module in colijunction wilh a CPU (e.g. 1M 467)
to
A CP in conjunction with R CPU (e.g. C P 342·5. CP 443 -5)
The,.., are "Class I ma
or .I~H' The OP .Ial'es are!h~ passive nodes on PROF!nus. in SL\1ATlC S7, B distinction is made bem'c~'Il
:>
Compacl DP slaves They behave like a sing le modtllc lowards the pr maSlcr
Compact PROFfBUS DP slaw,s Examples of 01' slaves includ e the ET200B (vers;on w ith digil,,1 input/output modules or analog inputioutpU! modulc~; degree of protee· tion II' 20; max . data transfer ra!e 12 Mb itls). the ET200c (rugged construction IT' 66/67; dif· ferent variant. w ith digita l inputs/outpUtS and analog inputs!outruts: data transfer Ta!e 1.5 Mbit/s or 12 Mb it/s) and the ET200L·SC (di •• crete modularity with freely combinable digital input/outpu t modules and analog inputloutput modules; degree o f protection IT' 20; data tra~S' fer rate 1.5 Mbitlsl· The bus gateways such as DP/AS . i link behave like a compact slave on PROFl BUS DJ'.
Modular PROFIBUS DP Jlave., The ET200M is an example of a madular DJ' slave. The design corresponds to an S7·300 sla· lion with DrN rail. power supply, Th-f 153 '1l!e rface module instead of the CPU and w ith up 10 R , ignal moouln (SMs) Or function modules (FM'l , The data transfer cate is 9.6 kbitls to 12 Mbitls. The ET200M can al.o be de,igned with (.lcli,'e bus modules if the DJ' master is an S 7.400 sta· lion. This means that the S7 ·300 input/output module. can be pl ugged in and removed during operation under power. Opera tion of the remaining madules continues. The mod ules no longer ha,·e to be plugged in without gaps, The ET200M ~an b( used with the 11>.1 153-3 interface module as a slave in a redundon, bus, The 1M 153·3 has rnro connec tions, one for the 1lT' master in the master station and une fN the DI' master in the standby station.
jntclligo:rll PROFfBUS DP slaws Eumplcs of intelligent DP slavcs arc CP Us with an intcgral DP (slave) interface, or an 57· 300 station with the CP 342 -5 communications processor. Equally, an ET200pro station with the 1M 154-g PN /DI' CPU interface N an ET200S station w ith the 1M 151·7 CPU inter. face module can be operated as intell igent DP slaves . RS 485 '""p e ater The RS 4S5 rel"'ater combines two bus seg· ments in a PROFIBU S subnet,vnrk. As a resu!!.
the number of stations ""d the cKponsion orthe suhnem-'ork can be increased. The repeater provides 'ignal regeneration and d.etrical i.olation. It can be operat.-d at trans m ission rme, up to 12 Mbit/s. including 4545 kbitls [orPROFIBUS PA. The RS 485 is nO! eonfigur~-J; it need only be considered when calculating the bu. parame· ters, Dl a gn ostles rep ea t er Using a diagnostics I~pca t er. you can detennine the topology and carry outl ine diagnostics in a PROFlfIUS segment (RS 485 copper cable) during runtime. The diagnostics r~-peater pro-vide, s ignal cc!!yn~mtion and electrical i,olation of the Con1)ccted segment s. The maximum segment length is 100 m in cach case; (~e (rans · mission rate can be between 9.6 kbivs and 12 Mbitls. The diagnostic. repealer has connection. fOT three bu. ,egment s. The cable from the DP mas!cr is connected to the infeed tenn inals of bu , ,egmcot DII. The two other connections DP2 and DP3 contain the test circuit, for deter· mination of thc topology and line d iagnostics on the eonne<:ted bus segments. Up to 9 funher diagnos tics repeater, can be e01)ne<;ted in series. Tbe diagnostics repe ater is handled like a DP sl ave in tbe mast~r system . In the event of a fault. it sends thc dctennined diagnostic, data to the DP master, These are the topology of the b us segment (sta!ions and cable lengths). the contents of the segm ent diagnostics buffers (last ten event, w ith fault in[unoation, location and cau,e) and the ,tatistics data (statement on quality of bus ,ystem). In additi(m, the diagnos. tics repeat~r proviM, monitoring functions for isochronc mode. Thc diagnostics data can be fetched and also graphicall y displayed hy a programmi ng device w ith STEP 7 \/5 .2 or later. Line diagnostics i. triggered from the USer program by the system funclion SFC 103 DP _TOPOL. and read us ing SFC 59 RD REC Or SfB 52 RDREC. In order to set the clock on Ihe diagnostics re~at eI. you read the CPU time using the system function
1.2 Distributed lfO
S FC I READ_CL K Rnd transmit it using SFC $8 \VR_REC or SFB 53 WRREC.
> A CPU with integral PROflNET interface
The {hasno~tic. repeater is configured and parameterized using STEP 7. A GSD file is available for opemtion on non-S~tAT!C ma.-
t>
A CP module in conjunction with a CPU (e.g. CP 343-1 )
10
dl" ·i e~
,=.
1.2.2
(e.lI . CPU 317-21'1'0101')
Th( 10 de,ices arc the passi,·c stations 011 !he PROFCIlET.in the case of SIMATIC S7. these can be the modular 1/0 devices such a~
PROFIN ET 10
PROFINET [0 offers a itandardizro interface for transmi .. ion of mainly binary proces> data betwe~n an '·imerfaee module·· in the (cemrnl) proilranunablc comroller and the field devices uiinlllndustrial Ethernet . This "interface mod· ule'· is referred to as lhe 10 controller and the field deVIces as 10 deviccs. The 10 courroller with all the 10 devices oonrrollcd by ;1 constirute a PROFINET 10 syslem.
ET200M. ET200S and ET200pm. The gateways PK'PN coupler. IE/PB link and IEiAS -i link nre 1l1so 10 d~vices. 10 su pHviSQr
10 supervisors arc dc\ ices for paramc'erization, Startup, diagnostics. and human machine imcrfacing, e.g. progmmming devi""s or HMJ de,·ices.
PRonz., I::T 10 system A I'ROFINET 10 "ystcm comprises th~ 10 con_
troller in the cemral stalion and the 10 devices (field devices) nsigned to it. The Industrial Ethernet subuet connectina them clm also bc shared by other sUitions and applications (Figure 1.5).
10 controller The 10 controller is the BCtive station on Ihe PROFr'lET. It exchanges data cyclically with '·its'· 10 devices. An [0 controller Can be:
IE/ PR linJ.
1.2.3
Actuator/Sensor
lnlHrac~
The Actuator/Sensor interface (AS-i) ;s
II ne tworking system for the lowcst process level in automation plantS in accordance with ,he international standard EN 30295. An AS-i master controls up 10 62 AS-i sla"es vi. a 2-wiT(: AS-i cable ,bal carries both the contfQl signals and the supply voLUIge. (figure 1.6).
One AS-i ""gment can be up \0 100 m in length: in combination with T(:pcatcrs and e",tension plugs. a maximum e",pansion of 600 m can b(: achieved.
I SIMATIC S7-300/400 Programmable Conuoller
"
Indy,niol Etheme,
PROFmUSDP
~
~ - link
AS·i IE/AS-; li"k
•
AS-i a
B;""'Y actuators a nd «n
AS-i .emo,
AS-i d"tributor
runhc:r AS·; do,'ioc,
Binary "motor< 000 S=or< without AS·i·ASIC
FIgure 1,6 Connecting the AS·i bu, 'ystcm to SII>lATiC S7 With "AS·lnterface SafelY at Work", you can safety sensors such"" em. rgencY-
AS·i master Standard AS·i masters can control up lD 31 standard AS·i , lave, with a maximum cycle lime 01'5 ms. In the ca, e of extended AS·i mas· lers, tllC quantity structur. increases 10 a maxi. mum of 62 AS-i slaves Wilh an extended ad· dress area Wi lh a maximum cycle time of 10 ms. Slave, with an extonded address area occupy one address in pair,; if standard slaves al"<' operated on an extended master. they each oc· cupy one addrc>s ,
The AS-I ma~lcr CP 343·2 is used in an S7·300 station or in an ET200M stalion. It supports tho foUowing AS·i slavc-s: c>
""
Standard slaves Slav~"
wilh extendcd addre"ing mod . (AlB
slaves) "" Analog slaves to slave profile 7.3 or 7.4
Inslandard mode,lh<' CP 343·2 behaves li ke an l'
o module: It occupies 16 input bytes and 16 out·
put bytes in the analog aililress area (from 128 upwards). Upto 31 standard slaves or 62 A/B slaves CilaV"" with ~xtendcd aJdross area) Can be op,:",t· ed on the CP 343 -2. The AS·i Sla'"C8 are paramc· teri and outputs. AS·; slave> with eXTe nded addressing mode (AlB slaves) ""cupy an address in pairs so that up 10 62 slave, can be operated 00 one maSler.
L2 Distribmed I/O
"A slaves" arc treated like standard slaves. and "1:1 slaves" arc addressed via data records. AS-; AlB slaves can al80 a~quire and transfer analog "alues
1.2.4
Gateway.
Gateways allow data exdmn gc k tween device, on different subnets, and the forwarding of configuration and parameterization in fonna_ tion beyond subnet boundaries (Figure 1.7). Conn.-cring two PROFIBUS .ubncts The Dl'lDP coupler (Version 2) conne<:ts m'O PROFIB US suboets to ~ach other, allowing you to exchange data berorecn the DP ma,ter'; , Both "ubnel< arc i,olated and can be operated at different data tram fer rates up to a maxim,un of 12 Mbi t/s , In hath .ubnets. the DPtDP coupler is as
Connecting PROFIBUS DP PROFIBUS PA
10
PROFlBUS PA (Praces. Automation) is a b.,< systcm for proce" engineering, halh for intrinsically-safc areas (Ex area Zone I). e .g. in the chem ical industry, as "ell as for non-intrinsically_,afe area< such as in the food and beverages industry, The protocol for PROFIBUS PA i, based on the standard EN 50170. Volume 2 (PROFlBUS DP), and lhe transmission technology is based on IEC 115H-2. There are two methods of linking PROFIBUS DP and PROFIBFS PA: I>
DP/PA coupler. when PROFIBUS DP can be operated at 45 .45 kbitls
I>
DP/PA link which converts the dala transfer ralC' of PROFlBUS DP to lhe data tramfer rate of PROFlBUS PA
The DP/l'A coupkr enables connection of PA field devices (() I'ROFlBUS DP. On PROFl BUS DP. the DPIPA coup ler is a DP slave that i, op
PN.'?N ""uple'
TfJPB link
Serial
1.7 Gateway.
33
I SI\lATIC S7_300/400 Programmable Cuntroller The DP/PA link enables the connection of I'A field devices to PROFlBUS OF with data tranSfer rates belwccn 9.6 kbitls and 12 jl,fbitls . A DI'/I'A link comprises an J),.j 157 interface module and up to 5 DP/PA ~cmplers that a1"<' connected to each other via SIMATlC S7 bus connectors . It maps the bus system consisting of all PROFlBUS FA segments to a PROFI BUS DP slave. A max imum of 31 PA fie ld devices can be connected per OP/PA linl..
link suppon, the procedures 3964R and free ASCII protocol.
SIMATIC POM (process De\~ce .\bnager, pre" iously SIPROM) is a cross-vendor too l for paramet~rization, startup and diagnostics of in _ telligent field devices with PROFlBUS PA or HART functionality. The DOL (Device Description Language) is available for parameter_ izing HART transducers (Highway Address able Remole Transducers).
The data transfer rale on PROFIBUS 01' can be up 10 12 Mbitls: RS 232C can be operated at up to 38.4 );bitl, wi th no pati ty_even or odd pati ty, 8 d ata bilS, and I stop bit.
From STEP 7 V5.1 SP3, the control technology modules arc parameterized with the Hardware Configuration; you must then no longer use SIMATICPOM. Connecti ng PROFIBUS 01' to the AS-I Ule rfate A DPfAS-Int~ rf:lce link "'Dable, the connection of PROfiBUS OJ' to the AS-Interface. On PROFIBUS OP, the link is a modular OP slave with a data Il1Insfer rate of up 10 12 .Mbitls in degree of protection lP 20. On the AS-Interface. it is an AS-i master that controls the AS-; slaVe!; , The link is available in the vers ions DPIAS_i Link 20£ and DPIAS-j Link Advanced. The following AS-; slaves cao ~ c011lwlled : t>
Standard .bves. AS-i aMlol! slaves
t>
Slaves with extended a
t>
Slaves with data transfer mechanIsms in accordance with AS_i spe<: ificalion V3 .0 (DP! AS-i Link Advanced)
C onnect ion of PROFlBCS j)p to a .erial interface The PROFIBUS DP/RS 232C link is a converter be!v.'een an RS 232C (\'.24) interface and PROFIBUS DP. Devices wi th an RS 2J2C inl<.>tface can be connected 10 PROFIBUS OP with the OPIRS 232C li nk. The DP/ RS 232C
The PROFlBUS OPfRS 232C linl< is connected to the dovice via a poinl-lo_point connection. Conwrsion to the PROFIBUS OP protocol takes place in the PROFIBUS OPfRS 232C link . The dala is transferred con,istently in both di1"<'ction<. Up 10 224 bytes of user data can be tnmsfe=d per message frame.
Connecllng two PROFlNET su bnets With the PN/PN Cou ple r, you connect two Ethernet subncts to each other in order to ex_ etlangc dam between the 10 controllers of both subne\S . The", is galvanic isolationlxtv..·ccn the subnets. The PN/P:"oI Coupler is a 120-mm-wide module tbat ii installed on a OrN rail. The subnets are connected using RJ45 connectors. Two connections with internal switch functi on are available for each suboe!. From the "ie''''point of the relevant 10 control· ler, the PNIPN Coupler i, an 10 device in its own PROFlNET 10 system. Both JO devices are linked by a data transfer area wim 256 input bytes and 256 output bytes, divisible into a maximum of 16 area,. Input areas in one subtlet must correspond to output areas in another The PNfDP Coupler is cont1gured and paranlC_ terized with STEP 7. A GSOML file is available for other con ilguring tools. Connection of PROFINET TO to PROnBl'S 01' You can connect the Industrial Etherne t subnetworks and PROFIBUS using the lEfJ'B link Pl\'IO. If you use PROFINET 10. me IE/ PB link PNlO takes over the role of a proxy for the DP slaves on lhe PROflBUS. An JO controlkr can access 01' slave, just like 10 devices us ing the IEIPB link. In standard mode, the lElPB link i, tran,parent for PO/OP communications and S7 routing ~twecn subnetworks.
1.3 Communications
The IF.JPB link PNIO is a double-width modul~ ofS7-3oo dcsign. The IEIPB link is connected to Indusnial Eth~rnet via an S-contact RJ4S socket. and to PROFIBUS via a 9-contact SUBD sockct . The IE/PB link is configured usins ST EP 7 as an 10 device lO which a DP master system is connected. When switching on, the subordinale Dr slaves are also provided with the configuration data from the 10 controller. Please note that limitations exist on the PROF!_ BUS DP following an IElPB link. For example. you cannot connect a DPIPA link, the DP segment does not have CIR capability. and isoch rone mode cannot be configured.
1.3
Communications
Communi cations _ data exchange betwe~"I1 progranunable modules - is an integral component of SlMAT1C 57. A lmost all communications functions are handled via the opernting system. You can exchange data without any additio nal hardware and w ith j ust one connecting cable between the two CPUs. If you use CP modules. you can achieve powerful network links and the facihty of linking to non-Siemens systems. SfMATIC NET is the umbrella term for SIMATIC communica1ions. It represents information exchange between progrnmmable conrrollers and between programmable controllers and human machine intcrface devices. There are various communications paths available depending On performance requiremcms .
Conn .. cting PROFlNET 10 to the AS_Interface I.J.!
Introduction
An IE/A S-i link enables the connec tion of PROFIN ET 10 to the AS-Interface. On PROF!NET 10, the link is an 10 device. On the AS-Interfacc. it is an AS_i mosier thai controls the AS-i slaves. The 10 controller can aCCe" the individual binary and analog values of the AS i slaves directly.
The most significant communications objects are initially SIMATIC stations Or non_Siemens devices between which you want to exchangc data . You require modules with communications capability here. With SIMATIC 57. all CPUs have an MPI interface over which they can handle communications.
Connection to PROF/NET is made via twO RJ45 connectors with internal switch function. The AS_lntcrfacc bus is conne<:tcd to 4-pin plug-in screw-type contacts
In addition. there arc communications proccssors (CPs) available that enable data e"change at highcr throughput rates ~nd with different protocols. You must link these modules via nct _ ..... orks. ,\ network is the hardware connection between communication nodes.
The link is avail~ble in the versions single master ~nd double master (in accordance with AS-Interface sp«:ification V3.0) for the connection of up to 62 AS-i slaves in each case and imcgra l analog value transfer. The following AS-i sla\'es can be controlled, to
Standard slaves. AS-i analog slaves
to
Slaves with extended addressing mode (AlB slav~s )
p.
Slaves with data mmsfer mechanisms in accordance with AS-i specification V3.0
The IE/AS-i link is configurcd and parameterized with STEP 7. A GSDML file is avajiable for othcr configuring tools.
Data is exchanged via a ··conn ection·· in aCcordance wilh a specifi c eXe<:U1ion plan C·communications ,crvice··) which is based, among other things . on a specific coordination procedu«: (" ·protoCor·). S7 connection i5 the standard between S7 modules with communications capability. for example . Using an S7 connection, f igure 1.8 shows thc objects involvcd in conunun ication between rv.·o stations. The uSCr program of the left_hand station contains the data to be lransmined in a data block (DB) . The conunun;cations function in the example is a system function block (SFB) . Assign the parameter RD with a pointer to the data to be sent. and trigger the transmission from the program. The communications
1 SIMATIC S7-300/400 Programmable Controller
5 1MATIC 57 station CPU
5 1MATIC 57 station
User program
System memory
Received data
Connection ID
Communications function
Bus interface of the module 5ubnet
System memory
CP Operating system
Connection resources Con'lec:.tiQD
Figure 1.8 Data Exchange Between Two SIMATIC S7 Stations
function is additionally assigned a connection ID with which the used connection is specified. The connection occupies a connection resource in the CPU's system memory. The data are transmitted e .g . to a CP module in another station via the module's bus interface. Connection resources are used in both the CP module and CPU. Because of the connection ill (and the configured connection path) the communications function in the receiver station "recognizes" the data addressed to it, and writes them into the data block of the user program by means of the pointer in parameter RD .
Communications serv ice A communications service determines how the
data are exchanged between communications nodes and how the data are to be handled. It is based on a protocol that describes , amongst other things, the coordination procedure between the communications nodes . Th e services mostly used with SIMATIC are: PG communications, OP communications, S7 basic communications, S7 communications, global data communications, PtP communications, S5-compatible communications (SENDI RECEIVE interface).
N etwork A network is a connection between sev eral devices for the purpose of communication . It
comprises one or more identical or different subnets linked together. Subnet In a subnet, all the communications nodes are linked via a hardware connection w ith uniform physical characteristics and transmission parameters, such as the data transfer rate, and they exchange data via a shared transmission procedure. SIMATIC recognizes MFI, PROFIBUS, Industrial Ethernet and point-to-point connection (PTP) as subnets.
36
Connection A connection defines the communications rela-
tionships between two communications nodes. It is the logical assignment of two nodes for
ex ecuting a specific communications service and also contains special properties such as the connection type (dynamic, static) and how it is established. SIMATIC recognizes the following connection types : S7 connection, S7 connection (fault-tolerant), point-to-point connection, FMS and FDL connections , ISO transport connection, ISO-on-T CP and TCP connections, UDP conn ection and e-mail connection.
1.3 Communicat ions
Communicatiun~
function!
The communications functions are the u,er program's intenaee to the communications sen'ice For SIMATIC S7 - internal communications. the communications functions are integrated in the operating system of the CPU and they arc called via system blocks. Loadable blocks are ava ilable for communication with non-Siemens devices via communications processors O v.. rvl" w of communications objects Table 1.1 shows the relationships ~tween subnet', modules wil h communications capability and communications services. In addition to the commun ications services shown, POtOP com munications is also possible via MPL PROFlBUS and Industri al Ethern~1 subnets. 1.3.2
Sub nelS
Subnet' are communications paths with the same physical characteristics and the same communication~ procedure. Subnets arc the central objects for communication in the SIMATIC Manager. The subnets differ in their perfonnance capability ; t>
MPI Low_cost method of networking a few SIMATlC devices with small data volume,.
t>
PROFTBUS High -speed e"change of small and mid range volumes of data. used primarily with distributed 110.
t>
t>
Industrial Ethernet Communications between computers and programmable controllers for high_'peed e"change of large volumes of data, also used with d istributed II0s (PROFC'lET 10). Poim-to-poim (PTP) Serial link between two communications partners with special protocols.
From STEP 7 Y5. you can use a programming device to reach SIMATIC S7 stations via subnets. for the purposes of, say, programming or parametcri"ing. The gateways between the subnelS must ~ located in an S7 station with "routing capabi lity".
l\ fP 1
Every CPU with SlMAT1C S7 has an " interface with multipoint capability" (multipoint interface. or MP!) . It enables establi.hment of subnets in which CPUs. human machine interface devices and programmmg devices can e"change data w ith each othur. Data e"change is handled via a Siemens proprictary p rotocol. The ma"inuUl1 number of nodes on the MPI network is 32 . Each node has access to the bus for a specific length of time and may send data frames. After this time, it passes the access rights to the next node ("token passing·· acceSS procedure). As transmission medium. MPI useS either a shiel ded twi'ted_pair cable o r a glass or plastic fl~r-optic cable. The ma"imum cable length in " bus segment with non_electrically_isolated interfaces i, up to 50 m depending un the transmission rate. and up to 1000 m with e lectrically isolated imerfaces. This can be increa,ed by inserting RS485 repeaters (up to 1100 m) or optical link modules (up to'" 100 kIn). The data transfer ratc ;s usually 187.5 kbit!s. Ove r an MPI subnet. you can exchange data between CPUs with global dam communi cations. sllIlion -c" temal S7 basic communications or S7 communications. No additioual module. arc required. PROFIBUS PROFlBUS stands for ··Process Field Bus" and is a vendor_independent standard complying with lEe 61158/EN 50170 for universal autOmat ion (PROFlBUS DP and PRO FIBUS FMS) and for process automation aceording 10 lEe 61158-2 (PROFIBUS PAl. The ma"imum number of node, in a PROFT BUS network is 127. where the network is divided into segment.s wi th up to 32 nodes . A distinction is made between active and passive nodes. An active node receives access rightS to Ihe bus for a specific length of time and Olay send data frames . After this timc. il passes the access rights to the ne"t node ("token passing" aCCeSS proccdnre).lfpassive nodes (slaves) are assigned to an aClive node (master). the master c"ccutes data e"change with the slaves assigned to it while it is in possession of the
37
1 SIMATiC S 7_300/400 Programmab le Controller
T_bl. 1.1 Communication,Objec"
SfC call'
" BUS
Dr interrace
(DP ma,ter Of DP ,lave)
SFB/SFC call,.
.,
CP 443 - ~
- --
Industrial
Station_internal 57 basic commun icati ons CP )42_3: PROfIDUS DP VO CP 433 _5 Ext.: PROFIBUS UP VI
~xl...,d.d
H.,.dwarc conliguflItion, SF BiS FC call.,
FMS int'-TIace CPU, with
I
PROFINET 10 (10 controller)
"
CP44.1·1 TCP/lP and C OP.
CP343-11T 57 cr 443·1 Advanced CP443 -1 1T
tah le,
38
1.3 Communicalioll5 access rights. A passive node <;\oxs not receive access righls The PROFIBUS network CRn al!l<) be physi~ally designed a.s an electrical network, optical nelwork or wireles§ couplina with various trans_ mission rates. The length ofa Sejmcttt depend. on the tranSmission ratc. ~ elcctrical network can be configured with a linear or!reC topology. 11 uSC!! • shielded. rw;,\ed two-wire cBble (RS485 inlerfaee). The transmission rate can be ~djuS!cd in steps from 9.6 kbitlS 10 !2 Mbiti, (31.25 kbitls with PROflBUS PAl. The oplieal network L1ses eilher plastic. PCF or lila" fiber-optic cables. 11 is suitable for large distanccs, provides electtical iSOlation. and is insen~ilive 10 electromaanetic inlerferences. The transmission ntte can be adju<1cd in <1epS from 9.6 kbitl. 10 12 Mbits. When using <>pli· cal link module. (OLMs), design:< arc possible wilh linear. ring or Star topologies. An OL:vI also provides the connection hClweC11 cl«trical and optical networb wilh a mixed design. A co~t-opt itllized version is the design a.~ a linear structure with integral interface and optical bus Icnninal (OST). lising the PROFTRU5 infrared link module (ILM). sinille or several PROFIBUS sla,''''' or I~gments can be provided wnh a wireless con_ nection to PROnSU5 slu,·cs. The maximum transmission rate of \.S Mb,,,s and Ihe ma.ximom rangc of IS til mean. ,hat commUniCalion i~ possible with moving parts, You implemcm connection of distribUlCd VO via D PROFIBUS subnetwork; the relevant PROHBL'S DP communic"ions service is implicit. You can ~ eitherCPUs with integral or plug-in DP master, or the rele~ant CPs. You cpn also nperate station-internal 57 basic com_ munications or S7 communications via this net_ work. You Can transfer data with PROFffiUS FMS and PROFIBU5 FDL us ina the relevant CPs. There are loadable blocks (F\15 interface nr SEND/RECEIVE interface) available as the interface 10 the user proaram). I nduSlrlal Et hernel Industrial E,hemet is the Jubnet for connecting complllcrs and programmable control lers, with
tlte focus 00 the industrial area. defined by the intc-mational standard IEEE 802.3/802.3u. The standard IEEE 802.11 alb/gib defines the con_ ne<:tion to wireless local area nel\>fOrks (WLANs) and Industrial Wir.,]ess LAN. (lWLA1'>s). The number ofst8tionl networked using Induslrial Elhernet is unlimited; up to 1014 stations arc penni.sible per segment. Sdore accessin&. each nodc check-< to §ee If anolher node is curremly tran,mining, !fthi. illhe case. the node waia for a mndorn time before attempting another access (C5MA/CD acces. procedure). All nodes have eq ual acce~.~ rillhts , The pbysical connections on Industrial Ethernet consist of point-Io-point conncctions bc1ween communication nodes. Eacb node is connected wilh precisely one paMer_ To enablc &e"eral nodes to communicatc with eacb othC'!". Ihey arc conn«tcd to a ··dtstnbutnr'· (swilch or hub) Iha, has scveral conncctions. A .,..-ITCh is an active bus elemcnl that regener_ Rtes signals, prioritizes them, and distribul<:s them only to Ihose devicc~ thai are connected to it. A h"b Kdjusts to thc lowest datu transfer rate at the ~onnttlions, and forwards all signals unpriOliti ...ed to all conne<:ted dcvices.
The n~tworlt" can be confiaured as a linear. star. ITCC or ring topology. The dala tramlfer rates Ill"<:> 10 \'fuitls, 100 Mbitl$ (FRS! Ethernet) or 1000 Mbitfs (Gigabit Ethernet, not on I'KOFrt.'ET), Industrial Ethernet can be ph)'~ically designed as nn electrical n~"1",otk. oplical nctwork or " 'ireleu network. FutConnccl TWisted Pai!"$ (FC TP) "ith RJ45 connections. or 1ndu.~triaJ Twisted Pai!"$ (ITP) with sub-D connections are available fOf implcmcnlina Ihe electrical cablina. Fiber optic (FO) cabling Can consi" of alass fiber. peF or POF. It ofT~n galvanic isolation, is impervious to elei.:.romagnetic influences, and is suilable for long distaJlccs. Wireless .ransmission uses the frequcn cics 2.4 GHz and 5 GHz with data transfer rates up to 54 Mbitll (dcpending on the national approvals), You can cxchange dala with 57 and IE communications via Industrial ElMnIe{ and utilize the S7 fUDCtions. With appmpriaICly designed modules. you can also establish ISO trnnspnn connCCtions. ISO-on-TCP connc~ t ions. TCP, UDP and e-mail connections,
"
I SIMATIC S,_300/400 Programmable Controller
PROFII'I,'ET
AS- I nt~rface
PROFINET i~ the open InduslIial Ethernet slanJard of PROFillUS International (PNO) _ PROFINET use, the Industrial Ethernel subnet a, the physical medium for data trmsmission, taking into ac~ ounl the requirements of indClStrial autolllillion . For examp le. PROFINET offer. a real_time (RT) response for eommWlication:; with field devices. and isochronou, real_time (IR1) transmission for motion control appl ications. Compatibilily with TCFlll' and the IT '1anda~ of Industrial Ethernet are retained.
The AS-Inlerfacc (.duatorlscnsOf interface , AS -i) networks the "ppropriately designed binary S<;"tlsors and actuators in accordance w ith tbc A S-lmcrface specification lEe TG 178. The AS-Interlace docs not appear in the SIMATIC Manager as a suimel, ""Iy the AS -I master is configured with the hardware configuration or wi th the network conliguration_
Siemens applies PROFlNl:T to two automation cOllcepts: ~
Component Based Auramalian (CllA) uses PROFINET for ~ommunicat ion bem-'e~n control unit, as components in di,uibuted systems . Th~ configl!Talion tool lS SIMATIC iMap_
~
PROFfNET 10 lISes PROFINET to transmit data to and from field d~Yices (dimibuu:d 110). "Ibc con fi guralion tool is SIMATiC STEP 7 .
Point_to-poiut
eonn~eti"D
A poiut-IO-point connection (PTP) enables dala uchangc via a serial link. A point_to_poinl CO llnection i< handled by the SI.MATIC Manager "s a .nbnet and configurc<1 ,imilurly. The tran"nission medium is an electri(al cable with int~'tfac e_dependent assignment. RS 232C ( V.24), 20 mA (TTY) and RS 4221485 are available a, interlace,. The data transfer rate is in the range 300 b it,,). tu 19.2 kbith with a 20 rnA interface or 76.8 kbit/s v.;th RS 232C and RS 42214~5. Th~ cahle length depends on \he physical interface and the dIlta transfer rate: it is 10 m with RS 232C, 1000 m w ith a 20 mA interfuee at 9.6 kbitl. and 1200 with RS 4221485 at 19.2 kbitls_ 3964 (R), RK 512, printer drivCl"S and an ASCn driver"", ""ai iable as protoco ls (proc cdur<"). Ib e latter enabling definition of a u,er_spec ific procedure.
The transmission medium is an unshielded twisted_pair cab k that ,upplics th e actuators and sensors with both data and power (power s upply r"'1 uircd). Netvwrk range can be up l<> 600 m with repeaters and extension p lugs The data transfer rate is set at 167 kbitls .
A maSter ""nlrots up to 62 slaves thro ugh cycli c scann ing and w gmlmntee' " defined ""pense "me.
1.3.3
Communication s ServlcO/"S
Data exchange over \he "ubnets i, control led by different communications servic e, - dq>cnding on the connection sdcetcJ. The services are provi ded by the CPU ,>r CP modules _ In addi· lion to communications wilh ficld devices (PROFIDUS DP, PROFlI:IUS PA .'ET 10, so:.: Chapler 1.2. I "I'ROflI:lUS DP " and t. 2.2 --PROFINET 10"), the service, listed be low arc available depending on the mooule u>ed.
J'G communication . 1'G communicalions i, used to exdlllnge data between an engineering station and a SIMATIC sta tion . II i. used. for example, by a programming device in online mode 10 C"Xe<:U1e the function, "Moni tor variables" or " Read diagnostics buff~r" or to load user programs . The ~ommuni ca tions functioru required for PC; commun ication, arC integrated in the operating system of the SIMATIC mooules . PG communications Can be c."'e<:uted over the MPl, PRO FIBUS and InJu,mal Ethernet subnets. By applying S7 routing, the PG communications '''III aho be used beyond , uhneK
1.3 Communications
OP communic ation> OP con>m"nkations i~ us~d to ~xchallg-e data between an operator stat ion and H S!MATIC statim' , For example, .1 io "sed by an HMI oe~iec for opcmtion ~n,j monitori!\g. or 10 read and Wrile variablcs. Tbe eomml.micatio!\s functions requircd for OP commll!\;cation~ are im,,gn.tcd 'n the opcratina system of the SL\{ATIC modules. O P communicauons can be excculcd overthc Ml'1, PROFlB US and l ndu~tri"l F ibernel ",hocts. S7
bY~lc
communicatIons
S7 \)asic eOmJl\oniicaUy when required. The communicillion~ fun ctions rO'l"i,...'<1 for th" S7 basic communicati ons are integrated in the opcratina sy.tem of the CPU, c,g. you triggcr thc data traM fer in the user pro· Iron! by mca!\S of system funetio'" Sf·C. StatiOll.internal S7 basic communications is necuted ov~r PROI'I HUS, .lJItion-c:xt~m81 oyer '\1 PI.
conlanee wi ,h RYC 793.1S0-
communk,.tlon~
Global data communi~ation. enahles e~~hange of~mal1 volumes ofdalli between s~veral CPUs with out ~dditional proirammin.: overhead in the user pro.:".m. Transfer Clm he cyclic or evenl.dri>'cn. The commulU~ali,)ns function. I'C'qUlred an: inregrated tn the openti".: system of the CPt:. Global
I'll' commun ications (poi~t.to· point connection) \Tnnsfe~ data o,·~r. ~crial intCTfa~e. e,g. hem-'een a SIVIATIC slition and a printer. Thc cummunications functionti requi red arc intcb'1'llted in th~ operating sy.tem. e.g. as system fW'lction blocks SFB. Olla uchan.:" is prn;siblc tHing various tJaru
S7 cn mmuuic"tion,
SS-i:(lmpatible
S7 ~('mmunicati(m";' an cvenl ..controlled service for exchanging laracr v()lume, of data bc!We~n CPU modllles with c()!\trol and lIle CPt: ($}ostem function blocks S FB) 0>" they are loadable function block>; (FB). S7 ""(Immunic,tion. can be: c~ccutcd o,er the Ml'l, PROFlBUS anrll.ndu>tri~1 Elhe rnet subnel s.
S!.compaliblc C
fF: communlcatlon WiLh "'Optn eommuruclttion via lndu5lrial Eth,,",cl·· (IE communicatiOn fO'l" shon). you tJ
~omm"nICltl ... n.
Slanda r d co mmunk,.,loM
Standard communicatiuns n~l'$ standardized, wndor-indc~ndent protocol, for m
41
I SI.MATIC S7-3001400 Programmable COnlroller PROF'lBU S F'MS (Fie1dbus Mc:....ge Specification) provides services for the programbaicd, device-indcpcndctlt ttansfer of suuccured variables (FMS variables) in accordance with EN 50170 Volume 2. Oam exchange is carried QUI using &tatic FMS connections over a PROFIBUS subnel. The communications functi on' arc loodable function blocks FB with which you COllirol the transfcr from the user program.
Using an IT communications processor, • S tMATle station;" linked to the IT ~'Hfl"'unl ullo n• . Tnmsfer over Industrial Ethernet comprises POIOP/S7 communications IIDd S5~om patible CQmmunieations (S END'RECE lVE) with the ISO, TCM P and lIFD U1lrI~port protocols. It is additionally possible to use SMTP (Simple Mail Transfer Protocol) for e-maH!, HTTP (Hyper Text Transfer Protocol) for ItCcen using Web browsers, and FTP (File Transfer Protocol) for program -controlled data nchRnitc with devices from diffcll'nl operating systems. 1.3.4
Co nnections
A connection is either dynalnic or slolic depending on the communications service selecled. Dynamic connections are DOl configured; their buildup Or c1eardo""." is e' ent-dri\ClI ('"Communications via non-configun.:d connections"). There can only ever be one non-conftiured connection to a communications pamer Stalic oonnections a~ configured in Ihe conneclion table: they are built up at Stle established in parallel \0 onc communication, partner. You use a "Connec!ion type" to select the desircd communicat ions service in the nct","OrIc configuration (see Chapter 2_4 -"Configwmg the N~
w<>ri<..,.
You do n()I need to configure connections ",'im the ~twork configuflnion fOJ global data communic.tions and PIWFlBUS DP or forS7 basic communications in the case of S1 fu~tions. Vou define the communications partl1CN for IIlobal datK communications in Inc global data table: in the case of PROFIBUS DP and S1
basic communications, you define the panncrs via the node addresses.
Conn ecrloo resoon ... Each connection requires connection I\.'$OUI"I:CS on the participating communications partner for Ihe en d point of the connection or Ihe tran_ sition point in a CP modulc. If, for example. S7 functions 8re executed via a bus interface orlhe CPU, a connection is aSlligncd in Ihe CPU: the i;IIIlC functions via the M P! interfaco of the CP occupy one connection in the CP and one eonncclion in the CPU_ Each CPU bas a specific Dumber of pos:sible tOnnectiorul_ Limitations and rules CJlist rcgard_ ing the use of connection rt'SOUl"CCS. For eltampie, not evCTY connection rc5OUt"a! can be u.sed for every type ofCQnne<:tion. One connection is reserved for a progranuning device Bnd one connection for an or (these cannot be used for any other purpose). Connection resources arc also required temporarily for the "non-configull'd connectiolU" in 57 basic communications.
1.4 1.4. 1
Module AddrcsSf.'S Signal Pat h
When you wiTC your machine or plant, you determine wltich signals all' connected whert' on the programmable comrol1er CFigun: 1.9). An input signal, for example the signal from momentary_contact switch +l tPOI- S lO. the o ne for "Switch motor on". is run 10 nn input modul •. wh.r~ it i, connecled to a specific lenninai. Thi~ terminal has an "address" called the 110 addrcs. (for instance byte S, bit 2). SefOR every program execulion Slart. the CPU then amomatically copies the sianal to the proeen input image, where it i5 then accessed t i an "input" address (I 5.2. for example)_ The cxprcs.ion "[ 5_2" is the absolute addrt'Sl. You can now give this input a name by "$ign_ IDit an alphanumeric symbol coITcsponding to Ihis input signal (such as "Switch motor on") to the absolmc address in thc symbol table. The
1.4 Module
T
" HPOI . L _SIO ( ..
,~,
., •
,,-
modulo
~'
Byten
•• •• •
., "' • 0
•• • .,
-, ._.
.,..
. .".
.
,
Process-image
1234 56 7
§, Byf1I
n~ I
-
A~
i:
----
11 -+
.
.,...
.""
Abso"'t"
~".
start add", . .
",,",a
r
~
U.", P
.... m (LAD) ~ s_ c "
on mo lor"
!"11m IFBDl USII' ~ S ... ;tc:h on motor"
II
15.2
II
,,~
-:::0-:::0-
I'lgu,,' 1.9
Co",,!ution ""<",,,,,n Modul. Add.r<: ••. AbwlU1e Add,« •• nd Symbolic Add, ... (P.,h of a Signal from Sonso< 10 s.canll;lIi III the Pmg""n) eltpl"C$$;on "Switch motor 00" is the symbolic addro:ss. 1.4.2
S lo t A ddress
Every slot bas a fi xed uddress in the progra mmable controller (an S7 stalion). This slot addreu cons;",s of the number of the mounting rack pnd the number of the slot. A module ;s uniquely described using the slot address ("geographical address·l. If the module contains interface cprds. each of these cards is also a~sii"cd a submodu1e add ress. In this way, each binary nnd analog
signal and eac h serial connection in tbe system hlu liS own unique addres~. Correspondingly, dislribuled UO modules also have a "geographical address". In this case, the number Of me DP master sys tem or the PR O F! /'-'TIT 10 system and the station nutnl:>er replace the rack number. You u~e STEP 7'5 "Hardware Configuration" tool 10 plan !.be hardware configuration of an S7 station as pcT the physitallOClltioo ofthc modules. Thi s tool also makes it Jl'O'Isible 10 set Ihe module start addresses and paramet"ri'!e me modulcs (see Chapter 2.3 '"Co nfiguring Stations").
I SIMATIC 57_3001400 Programmab le Controller
1.4,3
1.4.4
Logical Addu"
The logical addn:ss correspond, to the absolute address, U is also referred to as the user data address. for you uSe this aJJrc,s to access the user data of the input/output modules in the user program, either via thc process image (inputs I and outpulS 0) or direclly Qn \.be modules (peripheral inruts PI and reripheral outputs PQ) , The range of logical addresses comm~'IlCCS a t 7.cro and ends at an up!>"r limit ,pecifIC to I.hc CPU With digital mooules, the individua l signals (the individual bil<) a", combined into bWlChe, of g, rererred to as bytes. Modules exist with one . two or four bytes. These bytes have the relative addres"'s 0, L 2 and 3, addressing of the byte, commences at the modules stan address. E.umpie: wi!h a digital modnle with four byles and the ,tar! address 8, the individual bytes with add"",,,,s 8, 9. 10 and 11 addressed , Witb analog m<>dules, Ihe individlllli analog
=
Usitlg Ihe hardware configw-ation, you a,sign a logical addrc",~'S to each byte ora us<:d module. The address'" a"" assigned as standard starting at ~cro, but you call change the proposed add","" The logical addresse, ohhe individual modnles mll", not overlap. Th~ logical addresses are defined sqmralcly for \.be input and QUlput module.', so that an inpnt byte can have the same number as an output byte, The user data or Ihe distributed 110 an: also addressed in hyles using 3 logical address. In onkr to guaram"" an unambiguous a"ignmcnt of all user data of a CPU (or more exactly: all u",r data on a P bus), the logical aJd",sscs of Ihe distribuled 110 must not overlap with Ihe logical addresses of the central module<; It i. usually the case thaI the digital modules arc
assigned ac"ording to addrcsses in the process image so Ihat thcir .,i gnal
Module St art Add res.
n'e module start address is the smallest logkal (user data) add,e",e, of a module : it idcmifi"s the relative byte zero of the modu le , The fol_ lowing module bytes are then assigned succcs,iv ely with addrcsses . In the case o f m ixed modules containing inpu1 and output f""ge, . the lower range start address is defined as !hc module star! address . If Ihe inpot and output range, have the same start addn:«. u<;c Ihe input address ,
Using th e hardware wnfigurm ion. you determi ne the position ortbc US<.T data addresses in the address volumc or !he CPU by defining Ihe modul~ "an addressc •. The lowest logical addre" is also Ihe moduk .tart address for Ihe modules of the distributed JIO and even for the virtual siNS in the tIlIn.fer memory of an intel _ ligent DP , lave The modules ,tan addrcss is used in many cases to identify a module. Other than thi', it has no 'peeial meaning ,
104.5
D I"gn ostics Addrc ..
Appropriately equipped modules can ,upply diagnostics data that you can evaluate in your program. If ccntrali/.ed moduks have a user data address (module start address), you accesS 1he module via thi, addre.s when reading !he dia"'1l0Sli ~s data. If the modules have no USer data addn:s> (e.g. power supplies), or if they are part of Ihe distrib uted VO. thm' is a diagnosti cs add""" for this purpose. The diagnostics address is alw,"ys an address in Ihe 110 input arca and oC~1,!pics one byte. The mer data length of th is address is zero; if it i, located in the process image, as is pennillcd, il is not taken into account by th~ CPU whCl1 updating \.be pro<:css imag e. STEP 7 automatically ""signs the diagnostics address counting down from the highest possible 110 addres,. You can change the diagnostics addre~< with \.be Hardware Configurdtion funeIton The diagnost ics data can only he read w ith speci al system functions: accessing this add,..,,,s Wilh load "8Iemcnl, has no effect (see also Chapler 20.4 "Communicati()ll via Distributed VO").
1.4.6
i\dd...,sscs ror
Ru~
"odes
MI'I Module. that arc nodes on aD M l'l ne t,,"or\: (CPUs. FMs an d CP S) also have an " '11'1 addren. This address is decish'e ror !he link 10 programming devices. human machine interface devices and for glob.al data communicalionl. I'l~asc nOle lhat with older revision levels ofthc 57_300 CPU •. !he FM and C I' modules oper. aled in Ihe .arne Slat;on receive Hn MPI address derived fro m the MPI addrc~s of the CPU. In the case of newer S7-300 CPUs. the MPI addre.sc, of FM aod CP mndulc~ in thc ,ame sialion can he detennined independently oflhe MPI address o f the CPU. VKOf'lBUS DP EliCh 01' lItation (e.g. Dr maSter. DP slave. progTanuning device) on the I'ROFIBUS also has a node Md dre~s (station number) with which it can be unambiguously add resS\:d on thc bu s, I'ROFn<'ETIO Staliom on the Industrial E.thcrnct havc a faelory-SCt MAC . dd",~, ",hich is unique world_ wide. An II' ad d l"fi~ is addillonally reqoired for identification on the bus. and ,s configurcd for the 10 cOlltroller. Thc II' addresses for the 10 dc"icc~ are deri ved from thc ll' addr~ss of the 10 cOntrol ler. The 10 comrollcr (thc ,n terfdce) an d each 10 device i~ additionally assigned a dl"'"jce na nw. The 10 device IS addressed by the user program by m~anS of a dC" lcc number (stalion numbcT).
I>
Ibe L Stack. (sec Chapler III.I.S " Temporary Local Data")
To this are added the code an d data bloch with the block.·local variabl e~, depending Oil the user program. 1.5.1
User Data
A~a
In SlMATIC S7. each module can havc two areas: a user dala ar~a. wbich can be directly addressed with Load and Transfer Stalemems. and a syslem dala area for trallsfer_ rillg data records. addrcs~
\\'hen modules are access~". Ihey might. Inr uarnple. be conlro! or Rtatus infonn ation. The "olume of user daQl modu lc-Hpeei fic. There are modules tha! occopy onc. t .... o. four or more b>,es in this ...-ea. Addressing ah'1IY. begins at rcl~thc byte O. The address o f byte 0 iJ the module
'S
The user data represent the VO address area. divided . depend ing on Ih e dir<:ctiot! oftrnnsf~T, inlO peripheral input. (1' Is) and periph".,-al OUIpulS (PQ5). If the us"r data arc in the area of the process imag ..... the CPU automat ically hand les Ihe rrunsfcrs when updatinillhe process images. Pe rlphcra l lnpurs
1.5
A ddress Areas
The address areag available in every programmable cuntrolkr are !>
the peripberal inpulS and outpul'o
I;>
Ihe process input image and the process out_ put image
!>
Ibe bit memory area
I>
Ihe timer and eounler funclions (scc Chaplers 7 '""Timers" and 8 "Counlers"')
You use the peripheral input (PI) address area when you read from Ihe user dala area on input modu l c~. Part of'he PI ad dress area Icad. to the proces' image . This part alwuys l>cg in. at I/O addreu 0; the leogth of the an;a is CPU-specific. Wilh a Direct liO Read Opcllllion, you cllll acce$~ the modules whose intcrfaces do not lead to the proces< Input image (fOT instance nnalog input modules). The signal stateS of modu les that lead to Ihc proees. inpm image can also be r~ad with a Direct Rcad operation.
I SIMATTC 57·}00/400 Programmable Controll..-
The momentary signal states of the input bit ,
an: then ,ca nned. Please note that thi' 'ignal st"le may differ from the rdevant lnPuts in the prOCe>S image ,in~c the proc~S5 input im"g~ is urses a, peripheral outputs .
Pcrlpbc"aloutpuIS You u,e the peripheral outpUT (PQ) addre,s area whe"Jl you wriTe vnlu~s to the u'er data a~a on an OU(plit module. Pan of the PQ add~8s area leads TO Tbe process image. This part always begi ns at 1/0 address 0; the le ngth of lhe area is CPU_specific. With a Dire<:T I/O Write operaT ion. you can a~cess modules whose inK'Iface, do not lead to the process outpul image (su~h as analog output modules). 1bc sig,;al states of modules ~on' trolled by th~ process outr\lt im:.g~ ~an also be dir""lly aITcctcd. The signal statcs of the outpu1 bils th~n change immediately. Please nOte tha1:' Dirc~t I/O Write operation also upd ates the sig· nal S!.a\ CS of (he ~levant modules in the process output image! Thm. there is no di fTercnce betwcen the rrocess OUtpUT image and the sig. nal S!~tc~ on the output module •.
additional memory area sitnilarto the bit m=OIy area. Thi, appl ies both for the process input image and the process OUtpUT image.
On suitably oquirped CPUs. say. the CPU 417. tile size of the proce-s image can be parameterized. If you enlarge the proc~ss image, you reduce the size of The wOIk memory accord· ingly. Followin g a change 00 the ,iu oftl'c pro· cess image, the epe c"~eute, ini\iali zatioll of the workmcmory, with the same effe<:t as acold t~ S \art
Inp uts An input is an image of thc corresponding bit on" digiml input moduk. SC>UIJling an inp ut is th~ same as .canning the bit on 1he module it,clf. PriOI to program C~CCllli on in every program cycle. the CPU'~ operating sy'tem copie, the , ignal ,tate from the module to the proce" inpUT Image. Th~ use of a proce.s input image has many adv "mages:
<> Inputs can be scarmed and linked bil by bil (liO bits cannot be dircctly adilie,,,,d). I>
Peripheral OUtpUT' em re",rve the some obsolute addr~sse s as peripheral input'.
1.5.2
Process Image
The process image contain! the image of \.he digital input and digital outpUt mooul." and is thus divid~d into proce" input image and proce," OUTput image . The process input image 1.' ac~e"ed via (he addre', area for inputs (1), the procCICS O\J (PUI image v ia the addrC:ls arca for Oll(PUlS (Q). A. a rule, t h~ machine or process i, ~on(roned via the input' and outputs . The pr,x".. image ean be divided into suhs idiary proce" images that can be urJa,Ied either a uOOmatically or v ia the user pmgram. Please rs lmag: Updating" for more details. On the S7·3UO CI'U, and. from IO/9 ~. "1'0 on S7--400 CP Us, you can usc (hu addusses ofth. proce>s imagc not occupied by modules as
Scanning an input i, much faster lha" acce>s in g an inp ut module (for cx~mple. you avoid the transient rce"vcI)' 1ime o n the lIO bu" and {he system memury rc,ponse times are ,'horTer (han the module's response times). The pmgram i, therefore CKC<:UTCd that much mo~ quickly.
,. The signal State of an input i, \.he ,arne throughout the em ire pro"'ram cycle (the,"" is data cons i,tency throughout a program cycle). When a bi : on an input module change;;, Th e changc in the signal ;;tate i.' trans ferred TO thc inpu t at the ,tart of lhe next program cycle. "
lnplll, can ab o be set and re.et becaus e they are localed in random access memory. DigiTal input mod ules can only be rcad . Inputs can be set during debugging or startup to sim ulate ,Cn,OI Slates, thus sinlplifying program tes ting.
"Ib~,;e
advantage, arc offset by an increased progwm re'pome time (please also refer to Chapto: 20 .2.4 '"Re;;ponsc Time").
1.5 Address Area.
Outputs An outpu t is an image of the corrc'p,mding bit on a digi tal output module. Setting an output is the same as setting the bit on the output module it self. The cpe's operatin g system copies the signal state from the process output im age to the module . The use of a pn)l:e" output unage has many advantages: ~
Outputs can be set and reset bit by b it (direc\ addressing of L10 bits is not possible).
~
SeUin g an output is much fasler th an acc e ssing an output module (for example . you avoid the tramiem reeove.-y time on the L10 bus. and the system memory response times are ;;horter than the modulc response times). The program is there fore e~eeuted that mu~h more quickly
~
II. multiple s ignal state change at an oU!put during a program cycle does not affect the b i\ on the output module. It is the signal state of the ou!put at the end of lhe program cycle that is transferred 10 the module .
"
Outputs can a lso be scanned because they are located in random access mcmory. While;t is possible to write to digilal output modules. it is not poss ib le to read them. The scalming and linking of thc outputs makes additional storage uf thc oU!put bit to be scanned unnecessary.
These advantages are offset by an increased program response time. C hapter 20.2.4 "Respon se Time" describe~ how a programmable con troller'~ response time comes a!>out.
1.~ .3
Consistent User Data
Data cons istency m eans that data can be han d led ill a b lock. Transfcr ofa data block m ust not be interrupted. and it is not perm issibl e for the data source or target to be changed from the other end duritlg a transmissi on e ither. For examp lc. if you transfer four bytes ind iv idually. the Jransmirting program can b e interrupted by a program of h igkr prioritybctwccn each byte. and this progr.un cuu ld change Ihe data in the souree or target arca.
In th e case of direct access to user dala (loading and lransterring), the d ata are rcad and wriltt:n as b yte. won! or doublcword. The load and tmns f~,. instruetiolli<. upon which the MOVE !>ox w ith LADIFBD and the as~ignmcnt ofvariabIe s w ith elementary data types w ith SCl_ are ba;;ed. arc desi gned as interruptible . J f you w ish to transfer a data b lock wilh morc than four bytes w ithout interruption belween system memory and work memory. usc the systcm fu nction SFC g I L'BLKlVlOV. Data tran sfer betwcen a DP slave and DP master is cons istent for a complele slavc cven ife.g. the tran
I SIMATTC S7-300/400 Programmable Controller
1.5.4
Bit Memories
The area called bit memories holds what could be ..,garded "" the controllers "auxiliary wntaetors", !:lit memories arc used primarily for storing binary signal states . Thc bilS in this arca can be lTeatcd as outputs, but arc not ".xternalizoo", Bil mcmori~'S are located in the CPU's system memory area. and is thcrefo.., available at all times. The number ofbilS in bit memories is CPU-specific , Bit memories are used to store intennediate results that are valid beyond block \xlUndaries and are processed in more than one block. Beside, the data in global data blocks. the following are also available for storing intcnnediate results
o Temporary local data, which are available in all blocks but valid for the Current block call only. and
o Static local data. which arc available only in function blocks but valid o'"cr multiple block calls.
CPU i~ parameterized. Please rer.,- to Chapter 21,1.4 "Retentivity" for additional infonnation. Clock
m~m .. rics
Many procedures in the controller require a periodic signal. Such a signal can be imple. mented using timers (clock pulse generator). watchdog interrupts (time-controlled program execution). or simply by us ing clock memories. Clock mClllorics consist of bits wbose signal smles change periodically with a mark-to·spac~ ralio of I : I. The bits are combined into a byte, and correspond to lixed f..,quencies (Figure 1.10). You spedfy the numb<:rofc1ock memory b its when you parameterize the CPU. Please Dote that (he updating of clock memories is asynchronous to cx«ution of the main program
,
Clock memory byte
•
17 1 6 1 5
j41 3 1z l tlol
I 10H~
5 Hz (fllcke
Retentin bit memories Part of bit memories may be designated "reten· tive"'. which me""s that the bits in that pan of bit memories relain their signal state, e,en under off-circuit conditions. Retentivity always begins w ith mcmorybyte 0 and end, at the des· ignated location . Retet\\i vity is S<:t when tbe
.
,",
, ,25 Hz (nuh ing light)
, "'
0.625 Hz (slow flash ing light) 0.5 Hz F lgur~
1.1n Contents of the Clo
2 STEP 7 Programming Software
2
2.1
STEP 7 Programming Software
STEP 7 Basis Package
Thi s chapter describes the STEP 7 basic package, Ver;ion 5.4 SP3, Wh i!c Ihe fIrst chap ter presented an overview o f Ihe properties of the pTOgmmmable controller, this chapter tells you how to sel th~se pTOpenies , The. basic package contains the statement list (STL), ladder logic (LAD) and function block d iagr4tn (FBD) programming languagc"_ Tn addition to the basic package, optio n packages such as S7-SCL (Structured Control Language), 57 -GRAPH (sequence p lanning) and S7-H iGraph (>tate-trans it; on diagram) are a lso available .
2 .1 .1
ImTaliution
STEP 7 VS.4 is a n_bit application whi ch executes with MS Windows 2000 Profe>sional with SP4, MS Windows XI' Professional with S1'2, MS Windows ServcT 2003 S1'2 standard edition as workstation computer or MS Win_
dows Vista 32-Bil Ultimate and Business. MS Intemcl Explorer V6 .0
who.e size must be at lea S! twice lha! of the mllln memory. You should ensure lhere is sullic icnt memory on the drive contain ing YOllr pr
Ify
STEP 7 VS h as multi _user capabilil y, thaI is, a project tbat is stored, say, on a cen lral ""rver can be ediled simultan~
STEP 7 V5.4
Dein"allation of STEP 7 is carried OUl wi th the setup program or in the usual manner for MS Windows u,ing the "Software-' program in lhe Windows Control Panel.
2 STEP 7 Programming Softw=
2.1.2
Autum.llon LIcense Manager
A license (right of usc) is required to operate
STEP 7. This consists of the certificate of license and the electronic licen;;~ key. The licCIlse key is provided on the license key disk or a USB stick. A license key ~an be present on the license key disk. on a USB stick and on local or networked hard disks. A license key wi\] only function if it is present on a hard disk with write acce"" You use the A"wmalion License Manger to transfer and administer the license keys . Tn.tallation of the Automatic License Manager is a requirement for operating STEP 7, You can insmll the Automation License Manager together with STEP 7 or on its own.
Thc type of license key is defined in the ccrtificate of liC<.'tlse: '" Single License This license is applicable for an unlimited time. and perrni"ible on anyone computer. ~
Floating License This liccnse is applicable for an unlimited time. and provided for procurement yia a network .
(>
Trial License This license i, limitcd to 14 days. or to a certain number of days starting with ils in itial use , It can be used for testing and val idation.
(>
Upgrade License This li cense permits upgrading of an authorization/license key from a previous version to the current vLTsion.
During installation of STEP 7, licensing will be requested if an appropriate license key is not yet pre~nt on the hard disk You can also cany out licensing at a later point in time, The license key is saved on the hard disk in specially identified bl""ks. To prevent unintentional destruction of Ihe licen'" key. please observe the lnfonnation on the handling of license keys proYided in Ihe help functionofthe Automation License Manager
2.1.3
SII\-IATIC M.nager
The SIMAflC Manager is the main 1001 STEP 7: you will find its icon in Windows ,
III
The STMATlC Manager is started by doubleclicking on its icon. When first started. the project Wi7-&rd is displayed. This can be used for simple creation of new projects. You can deactivate it with the check box "Display Wizard on starting the SIMATlC Manager" since it can also be called. if r", is for familiarization. When you open example project ZEnO I_09_ STEP7_ Zcbra with Fn.E ~ OP~N, you will see the split project window: on the left is the snu clUre of me open object (the object hierarchy), and on the ngbt is the selected objo<-1 , Clicking on the box conta ining a plm sign in the left window displays additional levels of the stlUerure: sek'Cting an object in the left half of the window displays it, cOntCnts in the right halfof the window (Fig-
ure2.1). Under the SlMAT1C Manager. you work with the objects in the STEP 7 world. These "Iogica\"' objects correspond to "rear' objects in your plant. A proj~ct contains th.. entire plant. a sta· tion corresponds to a programmable controller. A projed may contain sewrnl station. con nected to one another. for example. via an MPI ,ublleL A Slation contains a CPU, and the CPU contains a program. in our case all S7 program, Th is program. in tllID. is a "container" for other objects, g
application s in offiine view. The objects shown ;n bold type are containers for other objects. All objcc15 in the Fi!!lIrc nre avuHable to YOll in th e omine view. These Ire Ihe object;; thaI are on the programming device's hard disk . If YOllr programming device is onlinc on I CPU (normallya I'LC u'Tllet system), you cln switch 10 the onlinc vicw by wlccllng VIEW ~ ():.,"1.I1'<1"i. This option displays yel another projCCt window containing the obj"""t~ on the destination device; the objects shown in iulies in the FigUre are then no 10ngC!" included.
You can sec from the title bar of the aClive project window whether you lire working omine or online. Forele8rer dIfferentiation. Ihe title bar and Ihe window title elUl be sct to a different color Ihan the om,nc w;ndow. For this purpose. select OI'TlONS ~ CUSTOl>l1ZE and modifY the entries in Ihe ··Vicw·· tab. Select OPTtOSS ~ CUSTOl>1t.Zt: to chan!! .. Ihc SIMATIC Manager's basic scnings. such as Ihe scssioll languagQ, the archive program and thc ",oragc location for projccts and librari es, and eonfigurinllthc archive program.
Edi ling sequl"nce. The following applies for the general edit; n!! of object" To selec, an objecl mCanS to click on it <.>nee with the mouse 50 that it is highlighted (this is pos~iblc in both halves <>fthe project window). To name a .. object meallS to click on the name of the ""lected object (a frame will PI'r>eat around the name and you can change the name In the window) or select the menu item EPlT ~ OBI1'= PIlOI'ERTlliS and clliinge the name: in Ihe dialog box. Willi some o bjeclS sucll as • CPU, you can only change the npme willi the relevant tool (application), in this case with lhe Hardware Configuralion. To open Oil objecl. doublc-click on thai objeC"l. Iflhe object is a container for other objecl5, the SIMATIC Manager d isplays Ihe contents oflhe object in the right half of the window. If the object i. on the low.".t bierarchical level. Ihe STh-lATiC \1anager stans the approprilite tool f.". editing the object (for instancc. doublcclicking on a block starts the editor. allowing the block 10 be editcd ). In thi. book. the menu itcmii in th~ standard menU bar al thc top of the window are describ<.:d
2 STEP 7 PruWummins Software
Con, aine, fo, aU dabl of. programmable conlrolier
MPI P I P PROFI8US,
Sub""'t
e",,,,,jo< tlle ne,wQrk pamm01C,",
Industrial EthlImet
"'tting f",. ,ul",," (fiu\"'ionan,;e~
Cont.l"or for.U d ota of
"n,.,; k software)
fl,. SI.\lATIC 3001400 slatlon
Confogura tk><> table
C<><\Iains \he "'{)n!igumtlon
,m.,,,,,, ""d the p.mmel"" t?r
,~.
mooules Con
. ,,~
lb. u •• r prugr.m
OmUli", the dc!i nition. of <1'<' «>rnmun i <.,;on. wnno<;' ions , he''''''''''' DOd., in a network
Connectloos
Cootaimr for aU dato of the "5Or p"'gr.m
""'!If\IDC"'' '
Symbol table
Co"'.in~r
for tbe
Con", i"" the of'rm""l, (- n.me,) to the ab""luio addI ....,s of ;;lobol dat. pro~r.m
.onrco. C"",.i~ 'he S<>un;" for \he mer program (~.¥, for STl ailtl SeL progra,ns)
Contain the """'piled daut roc tho configurntioo Ubie
Variable table$
Co"tain the vari.ble, foc rrwWt(>o";'\j1
' be ~.Il intorf""" for blocks ,n\egtllled in tho Cl'l)
t~e
2nd modif0nlr
not ."'Iln." to any h.rdw ....
",ilh ,h. """'e ltrue"'" as an S7 progrom ,hat i, '",igm>.1
'0 hard,,=c
(The undcriinMt objects arc on ly ptesent in the omine data llllOnagemenL) F igure Z,Z Object Hiera",hy in a STEP i Project
$y,te>n
2.1 STEP 7 !Jui. l'ackage II~ "Ixro.lor sequence.•. Programmers experienced in the usc of the op<:rator interface usc the icon~ from the toolbar. The u~c of thc riRhi mf)uS~ blmolf is very dfeelive. Clicking on "n object uncc with the right muu,;c bunon screcn~ II menu sho ..... ing the Cll""nt editing options.
tion blocks in colijl1nelion with program conversion) :. Tl-S7 Convening Rlock~ Contains addhiolial loadable nmctions a nd function blocks for the TI-S7 converter
> IEC Function Blocks 2. 1.4
Proj ~cn
Contains loadable functions for editing variables of Ihe eomple~ data types PATE_ AND_TL\l£ Bnd STRING
and lib ra ries
In STEP 7. the "main objects" althe lop of the object hier-ITchy an: projects and libraries. Stuning with STEP 7 V~.2, ~ou can combine projCCt~ and libraries into Ilmhiproj
I'roJecu are used for the
t>
Communication Blocks Conta ins loadable functions for controllin g CI' mo
1>
'ii.celianffiUS Block< C.IIntains block!; for time SUtmping and time synchronization
~y~teftUl.lic
storing of dilla and programs needed for solving an automalion task. E5Sentially, these arc I>
Ihe halth"are configuratioo data.
I>
Ihe parameterization dala for the modules.
I>
the configuring dala for communicatiot\ via networks,
t>
the programs (code and data. symbols. souKes).
The objects in a project life arn.nged hi...-archi_ cally. The opening of. project is the: AAt step in editing all (subordmate) obje<:ts "hich Ihat object contains. The following sections discuss how 10 cditthe
components. Librarics an.: u'lIlttlized hierarchi~all)'. They may contain STEP 7 pwgmms which in tum may conmin a USer program (a coolo.iner for compiled hlocks), • container f.llr source progrnms. and a symbol table_ With the exception.llf online connecti.llns (DD debugging plbsiblc). Ihe crealion ofa proiflUll or proiJ1lm .celien in a library provides the same function_ alily as in an objecl. As suppl ied, STEP 7 V5 provides the Slmidard Library containing thc followini: prollTams:
> PID Control Blocks Cont.ltlns loadablc function clOS<.'d -loop centrol t>
block!; for
OrganJ~ation Block, Contains the templatcs feT the organization block. (es
Yeu will lind an <"'en'iew of the con,ents of these librarics in Chl!.pu:r 2S "l:ilock Libraries-. Should )'OU. f.llr c~amplc. pUKhase lID 57 module with standard blocks. the associated installalion progIaIll instails the sllIndard blocks 8.'l a library on the hard disk. You Can then copy these blocks from the library 10 your project. A \ibmry is opened with FILl! -+ OrLO.."': , and can then be cdited in the same WHy as a project. You can BI~ creatc y.llur .IIWI'I lohraries. The m=" ;'CTTl FILl! -+ N~w gencn.. c. a new obJC<:1 al the top of the objcet hio:rarehy (project, library). The location in the directory structure wbe'" Ihc SThiATIC Manager is t.ll create a project Dr library must be specifi..d under the menu item OI'T10S~ -+ CUSTOMt7.ll Dr in lhe "Ncw dialog" ho~
(>
System f unction Blocks Contains tho: call inl~-rf.c<:s of thc .ystem blocks for offline pro8fllmming integrated m the C[,U
The 'I'SfoR T menu is us..d 10 add new obj~''''s 10 c~isting ones (such .s adding a new block 10 a progr~m). Before doing so, however, you muSI firsl select the object ~vnUliner in whieh you want 10 insenthc ncw object from the left half oftbe SIMATIC Manager wind.llw.
I>
S5-S7 Convening Blocks Contain.,; loadabl~ functiom fo, the S51S7 convertcr (replacement of S5 standard fune_
You eopy obj~"C1 conlainers and .IIbjects with EDrr -+ COpy and EOIT -+ PASTE or. as is usnal willI Wind",.... by dragging the sc lceled object
r
2 STEP 7 Programming Software
with the mouse from onc window and dropping it in another. Please note that you cannot undo deletion of an object Or an object container in the SI"1ATIC Manager.
2.1.5
Mult ip roject.
In a multiproj ect. proj ..><:IS and librari es arc combined in an entity. The mult iprojccl allow, pruc~"sing o f communicat ions conncdiOnl; such as 57 connections between the projects. A mulliproject can then be handled almo.t like a s ing le project. Limitations : stations comlccled together by means of direc t data exchange ("internode communication") or through global data communication must be P,,",SCnI in the
Tests & troubleshooting, as wel l as SIMAT IC on the Internet Hap ---> CON1EXT-S E..';STTTVE HELP F I provides context-sensitive help, i.e. if you p re ss Fl, you ge t irl fonnatiorl cOrlcerning an object selected by th~ mouse or concerning the current error message.
In the symbol bar, then: is a b utton with arl arrOw and a questiorl mark . If you di ~k on this bulton, a questiorl mark is added to the mOuse poin ter. With this " Help " m OU8e pointer. you c an now click on an o bj e ct on the scre.:rl, e ,g . a symbol or a menu command, arld you wi ll gCt the associated online help.
"arne project, In a muitiproject. it is possible to carry out paralld processing of ind ividu al projects by vari_
ous
cmployc~s
without problem . The individ·
ual projects can be pre,em in different dire<:tories in a networked environment . The croSsproj ect fu nctions, such as thc match ing of ,ub networks and connection.<, are then carn ed oUi centrally when processing the multiptoj«:t, In the case of central SlOrage on a s erver, only th ~ operaling systems MS W indows 2000 Server and MS Windows Server 2003 are pcnn;llcd It is a ls o advantageous to create a muitiproject if yo " wish to make th e individual proj ects sm aller and clearer.
2.1.6
Online Help
The SI"tATi C Manager's online help provi des infonnation you need during your programming se ss ion without the need to refer to hardcopy manuals. You can sele CO:-'OEN TS ,tarts the central STE P 7
Help function from any application. This contains all the bosic knowledge, If you click on the -'Home" symbol in the menu bar (start page), you will be provid ed with an introdu~ tion to the centra l topi~s of STEP 7: Starting with STEP 7. Confi guring & programm irlg.
2.2
E d i ting Projects
\Vhen you sct up a project, you create "coma irl erg'" for the rcsuitirlg data, therl you generate the data and fill these containers , .'Ionnally. you cr~ate a project w ith the rel e vant hardware. configuro the hardware, or at Icast the CPU, arld receive in return containers for the user program. However, you can also PUl an S7 program d irectly into the project conmirler withom involving any hardware at all ).jete that irlitial izing o f tho modules (address modificatiorls. CPU settings, c on fi guring COrlnections) is po ssible only with the H ardware Configuratiorl tool We strongly recomm end that the entire proj ect editing process be carried out using the SIMATIC Manager. Creating, copying or deleting dire~\Ori es or files as well as changing name< (') witb the Wirldows ExplOl"<'r within th e Slmcture o f a project carl cause problems with the SI1>tATIC M anager,
2.2. 1
C r eating P rojects
Project "izard The STEP 7 Wizard helps you irl crcatirlg a new projecl . You specify the CPU us ed and the w izard c reates for you a p roject with an 57 station an d the s c1ecl ed C PU as we ll a.\ an S7 program container, a SOurce comainer and a b lock cot)tainer w ith th e selected orgarl izatiOrl block...
2.2 Edilinll J>roje<:ls
''''cw plI.orrcr· WIZNW.
the hanlwa~ configuration. the open station no" al$O shows the CPU .
CrT.Unlt a
When it configuTl:s the CPU. the StMATIC Manager also c~ate s an S7 program with all obj~ls. The project StruCture is now ~ornpl etc.
You
~Iart
Ibe
proj~1
proj~et
wi zard using fILE .....
"ilh th e 57 stllll"n
If you ,,'anI 10 ~r~ale a project "",an
C....aring a "e"'proj'",,1 5d~1 F u.E ..... NEW. enter a name in the dialog box. change the type and siorage lor;&l;on if n~e$~pl)'. and confinn with "OK" or RETURN, /nsenil'R a nrw station in II,,, project S~ICCI
the proj~t and insert .. suuion wilh I:-SERT ..... STATIO:- ..... Sl\IATIC 300 ST,\TIO:(in Ibis CaR an 57-3(0). Confi!,.",rill!:" ~1"tjQlI
Click on the plus box next to the project in Ihe lell half of the proj~t ""ndow and .elKt the statio,,: the Sf'iATIC Manager display, the Ilardwan:: object in the ri~t hal r of the wmdow. Doubl e·elicking on H"",/wur-e starts the Hardware Con tlguntlion 1<>(11. with which you edit Ihe ,"nfiguration tables. If the module catalog is nOI OD the scree". call it up wilh VIEW ----> CATALOO. You begin cunfiguring by selecting the rail with tbe mouse, fur instance under "SJ,\L\T1C 300" and "RACK 300". "holding" it, d'dggini it \0 tile free ponion in the upper luM of the $talion "-;nd",,, and " Iening it go" (drug & drop). You tllen oce .. table rcpreSt.'Uling the SIOI8 01\ thc mil. Next. "clect tile requi~d modules from (he module ~~talog and, using the pro<:~'
17.....;ns Ihe com"n/! o/IM S7 program Open the CPU; in the right half of the proj~'C1 ",indo"- you ,,;11 sec the symbols for the S7 prog"am and for the connection whle. ~n the 57 program: the SIMATIC "1anager displays tbe .ymbol. for the compil ed user program (tbe compiit,d blocks). the container fO<' the source prognrnu. and the symbol tablc in [he right balfofthc window.
Open the user "rogrnm (Bloch); the SIMATIC Mannier d i~plays the symbols for the compiled configuration data (Syslem dalo) and Btl emply orvanizsllOD blor;k for the main program (OB I) in the ngh! halfofthe window. Ed/ring user progr"''' objects We have now arrived at !he lowest level of the object hierarchy. The first lime: 08 I is ol,,:ned. the window with the objcct properties is displayed and the editor newed 10 edit the program In the organi~ation block is opened. You add anotber em pty block for incremental editin g by opening lN~[RT ..... S7 BlOCK -+ (Blocb must be highliahted) and scl~ting the requi~d hlock type from the lisl provided.
\\1I<:n opened. the .s)'~I"'m dmo object shows a list o f uvuila ble system dnla blocks. You receive The compiled con fi guration datu. Thes~ fy stem data blocks are editW via the llarm.·"r;: ohject in th~ eomai""r .varlo". You can lfIIlUlfc-r SJ'~ lem dala to the CPU with PlC ----> DOw:-rwlill and paramcterize the C PU in this way. The objC¢i container 5oll":"" is empty. With Snurc~ selected , you can ~elecl I' E.'Cl FR'iAL SouRCE to 1JltlI.rer a source leKt file created,
2 STF.P 7 PruIlTII.mmin, Soft",'.", ~I[ Sele<:tthe projcetllmll!'~l1ernte an 57 progrnm with Il-SER1 ..... I'1\OO~M ..... 57-PROU1\A.\1, UndCT Ihis S7 program, Ihe SIMATIC Manag~r ereat~ the objecl contairICMI So"rce,~ and Bloc-la, Blocks eOD ... ill5 un empty OB I ,
CITa lin g a library You can also ~.te • program under a library. for in~tat>l.'<.: if you "ani \0 usc it more than once. In thi~ way. the standard program i~ a1",-a)'S avsilable and y"" can copy it enti«: or in part into your current program. Please Dote Ihut yuu ell!llWt ~tabli~h online coMCCtiuos in ~ libnuy. which mean~ Ihat ynu cun debug a STIlP 7 program only wilhin a project. 2.2.2
J\lanwglnll' An:bJvlnS(
~t'()I·IIYnl/.lnw
The SIMATIC MRnager
and
ma;ntain~
a list of all
known "main object~". arrangcd I,ccording to user proje<:ts, Hbrurin, example projects ~Tld multiproject • . You in.t,,)\ the examrle rroject< ""d Ihe srand~rd tibr ..ric~ in conjunc tion wjtb STEP 7 and you install the u~er proje<:ts, th~ muhiprojeets and your own libraries yourself. When yuu c~ccute FI\.F ..... MANM;E, Ibe SIMAllC Manager ~how.' you ~ Jist of all k.nown projecl5 and libraries wilb nHme und path. You Can then deletc from the li~t projects or librnrie~ y"" no lonll~r want to d isplay ("Hide') or include in Ihc list new pl"ojc«s and libraries ("Display"). When il executes f ILE ..... RJ:.oRnANlZE. Ihe SIMATIC M IUlaIll"f c1imin~teli thc saps created by dd~-tions and opl;m;n:s dat.a memory similarly to the way a deftagmen ... tion propm optimiz~ the: da ... memory on the hard di.le. Tbe rcorgani~ation can take some time. d"pcncling on the dat& mo,'crnerus involved. You can al.o archive a project or library (Fu_" .... A R('HlVF;). In this case. the STMATIC Manag~r
storc$ the selected object (the project or library dire<:tory wilh all subdirectories and tiles) in compTl:ued fonn ;n an =biv" file.
From STEP 7 VS.4 SPJ, Ih e archive prolP"am PKZip VS.6 CLI is supplied for arch ivin8 and dearcb iving proj~"CtS ~nd libraries (the archive
progrnm ARJ.cxe is not suitable for MS Wi n00"'" Vista). You can ulso open A RJ archives ....·i'h PKZip V8.6 CU. Projecr.. and libraries cannot be edited in tbe "",hi>'w (compressed) st~tc. You can unpack an archiv~d object "~th Fll.E ..... R£I1UEVE and then you can edit it further. The rctrieved objccts ~TC automatically ac<.:cplcd mto Ibe project or libmry management ~tem. You make the .-.cUing. fot archiving and retriev_ ing on the .. ATChi,...... tab undCO' OPTIONS -+ CL'STO~I1Zr;; e.g. setling the tarset d irectory for archiving and rclrie .. ing or ''Generate arch ive palh aU1omatically~ (then no addilional specificatinns are rc-quircd when archiving hceause the DIme o f the archive file is genernted from Ihe pmjecI name) . Anbivlng a project in the CPU With the "Ppro priatcly de, igned CPU • . you
~"n
'l<>Ie " project in archived (comp ..... . ed) form in
the load m~'lllory of the CPU, \hat j,. Oil th~ memory card. Tn this way. you ~a" save all pIOj~ct data ~ircd for full eXe<:u tion of the uSeT P"Opam, such as ~y mb[)b or !IO"rce fole~, direct at the machine or plant. If it i>e<:omel oe<:e ..ary to modify [)T supplemenT the progT'dIIl, y[)U load the locally Stored data QtlIO the h~Td di 'k, correct the uscr progr:om, a nd ss .. e the up_to_date ptoj<:C1 data aKai n 10 the CPU. loading lhe proje<:1 data onto a memory ~3rd or micro memory .ard plugged into tho: CPU, open the proje<:t, mule the CI'U and scle<:t PLC ..... SA\'E TO fo.IDlORY CARD. In the reverse direction, lransfer the siored data ~k to the progrnmming device with PI.C ..... RFTltTl'vJ; t'ROM MEMORY C.o.RD_ l'1ease note Iha' when you write to a memory card plugged into the CPU, the entire eontenL~ o f tbe load memory IlR" ",TitlC1l 10 the CPU. including the .' Y"tcm data and the user P"'l7"m •. \\"h~n
Tfyou ,,"ant 10 fetch back thc projcctda ... SIOred on Ihe CPU without ereatinK a projecl on the
hard d isk,
2.2 Editing Pmjo:<:l$ 2.2.3
Proj eCf Version s
Since STEP 7 VS has become availabk. Iberc are three diffc['l:ru "ersiolt5 of SL\fAT1C pmjetts. STEP 7 VI creales version 1 projO"Cts. ST EP 7 V2 creal ~s version 2 projects, and STEP 7 V3!V4IVS.O can be used to create and edit both v.... ion 2 and '~I'$ion 3 projects. Wilb STEP 7 (rom venion VS .I . you C~n create and ed it V3 projectS and V3 libraries. If you IuIvc a vcrsion I project. you can couvert
Up to STEP 7 Ven;ion 5.3 you can comCTt a V I proj.ct to II V2 project with FlU, -+ OrEN \11::11.510N I PROJI:CT . With fILE
-+ OPEN. you can
open a V2 project and oonvert il iO a V3 project. I! is DOL possible to ereate a V2 project OT save
a project as a V2 project. 2.1..1
C fi!ltlng a nd cd ll ing m u l1iproj ...... "
u.ing Fn.E -+ NIoW you can crente a new mulliproj....,t in Ibe SIMAT1C Manager in which ~Muhiproj....,f'
it into a """,ion 2 projett with F1L£ -+ OI'D>
you
VliRS10'l I I'ROJECf. Thc project StruCture ...ith th e programs, Ihe comp iled version I bloch , the STL soun::c programs. Ihe symbol tabl e and tIM> hard"llrc c
101100". With the multiproj....,t Klectoo. you can then gcnc1"Btc a new project or a DCW library in the mulLiproject noing Fn.E -+ Ml:U1 PROlt:CT -+ CREATE IN ~1ULTU'ROIECT. You Can pm«SII the OC\\ Iy crealed project or libnlry a. described in the previous ~haplen , Using FILIo -+ MU1.TI_ PROJECT -+ INSEII.T INfO MULTIPROJECI' you can incorponlle exiSlin~ projecl~ Ind libniries
YOll Clln create and edit venion 2 pmjects wilh STEP 7 versions V2, V3, V4 and V5,O (Figure 1.3). STEP 7 V5.1 works only with "crsion 3 proj""lS .
Os the t)'1X' in the dia.
into the mUhiprojccl.
"
2 STEP 7 I'rogrammini:C Software
You can a l$O chminate projecl' and libnLri;:s agam from the mulliprojccl: marl: I~ projeclS; library. 8f1d !It'lect Fn.1i ---.. hluLnPROffiCT-+ Rl:.MOVI! fROM MUlll1'ROJECT. The project ot library is nOI deleted in Ihis process. Usi n.: f lU: -+ M UlT1PRO]ECl -+ ADm~T PROJECTS you can stan a wizard which .Iupfl
The mCflU cOlIlllllllllls FILE __ SAVt:AS. FILE-+ Rr.oRClA).,'flF, FR.b -+ k iANAGE and FILE -+ ARCHIVIl can also be u>ed on a muhiproject. and runction as wilh a sing:le project (~cc t:huptcr 2.2.2 "Managing, Reorganizing: and Mhiving'·). In the same manner. archived mult iprojl~tJ can be transferred to the load m~mory ofa ~orrcspond ingly desigocd CPU, Then: ar~ limitalions when archiving a multiprojecl whose comPQII;:ln~ are di stributed among nelwort drives.
2.3
Cunfiguring Stations
You UiIC the Hardwatt ConfigumfJon 1001 to plan your programmabl~ controllers configuralion. Configurin.: is carried out umine without connection 10 the CPU. You can also use th is 1001 to addrc~~ and param~teri~~ the modules. You can Cl'eale Lhe hardware oonfigurntion at the planning stagc or you can wait umil the hardware has already ret.'Il installed. You stan the hardwlll'e confill"f8.tion by sdectiug lhe ~tat;on and then EDIT ..... 01'9' OIlJ~CT or by oouhle-clicking 0fI the HanlHv~ ubi"" in the opened container SIMA TIC JO(M()() Sta· lion. You make t~ basic sening.< of Ib\; Iw'tlware configuration wiLh OPTIONS -+ CUSTOM\.L1l.
Whrm configuring has berm completed, ST .... nON -+ CONSJSTer-'t"Y CHECK will show you
wheth~ your <:limes well' free of e lTOrs. STAllOS ..... SAVE stores t~ configuration "'bl.-.; with all parameter lWIignm~nl data in yoor project on the hard diu.
STATION --> SAVE o\l'o"D CO~II'Iu! I\Ot only saves hut alck.<, Aficr compilinl!, you can tr;msfer the config\\ralion data to 8 CPU with PLC -+ L>oWr-LOAl.l. The r>bje~t Sy~rem dam in th~ online contaiocl 81ucks n:presents the current confi.:unllion dala otI thc CPU. You can '"return·· th~"SC rJ~tH [0 the hard diu with PLC __ UPLOAtI. You u·port the data oftbe h.ardW8I"C cunfiguralion ....ith STATION .... t:.xI'ORT. STEP 7 then creates a file in ASCII format that contains the configuration dala and parameterization data of tl1.e modules. You can cl1.OOlSC between a texl fonnat that conta;'l. Ihe daLII in ·'readable'· English. charncters, Or a comp8l'1 format with hexadecim al data. You can also impon Ii cOlTespondingly structured ASCII filc. Ch N:k sum Hardware Configuration g~"fICT'\Itu Ii via a cOlTCCtly compiled ~tat'otI and ~to~s it in the ~ySlem data. Identical system ~"Onfigurations have the samc checksum so that you can. for example, easily cumpare an online conJigUllition ".'!h an offline configuration. The
ch~lcl;um
The checksum i. a property of the S,"SIcm daln To read the ch~"<:ksllm. Opel'lthe Blocks
obj~(.
cuntain~r in the S7 proa:ram. IOelect the Sy.otem dara objcct and open it with EL:lIT -+ OPE.."I OWlCT.
The user program also has an appropriate checbum , You can fi nd thi~ alons with the checbum of the system data in Ib.t properti~~ o f Bloch: select the BlQCb container and then EDJT -+ ORJECT PR01>F.ltTII:.S on the "Check~um5"mb.
St illon ... indow When oproed. the Hardwa~ Configuration displays Iht .tation window and the hardware call1iog (Figure 2.4). F.n1"'l!e or maximizc the .1ation wimlow 10 facilitate editing. In t~ "'PIX'r section, it displays thc 57 slati ons in Ihc
2.3 Confil/Uring Stations
Hi" ....
l.~
Example of. Sta';
form of tables (one 1"" mOUntinll rack) that are <:onnected together via iOlcnace modules when severnl mounting rach are uS«! Wben distrib. uted UO is conne<:ted, tbe confillur"t.ion of the Dr master system or the PROFINET TO sy'" te'n ;s specified. with Ihe OP ~lation' and TO devices represented in Ihe fonn of symbols. The lower section of the station window sho",~ Ihe configuration table that gives a d~tailed view of th<: rack or OP slave selected in the upper "",ction.
InSlalllnl b udwan
Product SU ppOM inform ation H a rdWlI rt u tal"g
You can faue the hardware catalog in and out with VllW ----jo CATA1.OO. 11 conta ins all avail_ able mO
With HELP -+ PRODUCT !';VPI'OIlT u,"FORM.<.you can display infonnat;on from the [mernet for tbe sckctcd module. You muSI fint enllblc this function with OPTIO"S -+ CUSTOMII I and set a valid Intcrnet addre8s. Thc selected module can be in the hardwan: catalog Of already in the configun:d rack.
TlON
Co nn gur.tloD t.ble The Hardware Confilllll'lllion 10Ql works with tables that tach represent an S7 station (a mounting r~ck), a DP stalion o r an 10 device. A
2 5TF:P 1 Proll",mming Soft"......, C(lnfigurafion tahle shows Ibc: slots with tbe modules ammg<:d in the slotJ; or the propeT1ie~ of the modul" such as Ibc:ir addn:ss<:s Ind ordcrnumbcrs. A double-click on a module hne opens the properties window oethe module and allows Jnl1Imeter1zation of the module.
properties for \bf; n::le'"lInt rnQdules in the tab. If )'cs~
u\ c~.
2.J. I
Arrlnglng Mod ules
You begin configurin g by s<; lcctinii and "holding" the rail from the module catalog. for instanc~ under "S!MATIC 300" and "RACK 300". wit h the mouse, dragging it 10 the upper half of the 'fation window, and dropping i1 anywhen:: in that window (drag & drop), An empty eontigun.tion table is screened for \bf; central rack. NCOICI, 5Clce1 the required module! !Tom the module eafalog and, in the manner o:k:seribed above, drag and drop them in the appropriate ,10\5. The perrni>sih!e slolll have _ g~n background. A "No Parking" symbol te ll s you cannot drop the sdcc\cd modu le at the intcnded ,lot. You can abo mark the slot to be equ ipped. and sclt(:t IN5~Il.T -+ INSERT OBJECT. In a popup window, !he Hardware Configuration then shows you a ll modules penni.sihle for thi, slot. from which you can selC'Ct otIC. In the case of!ingle-tler S7-300 stations, slot 3 remains empty; it is reserved for the immaee module 10 the expansion mck, You can generate the eonfigunt.tion table for another nck hy dragging the scle<:ted raclr:: from the e8talo& and dropping it in the sumon ,,'indow. In S1-400 systems, a non- int~onflCeted nick (or more precisely: the relevant r«ei"e interfnce module) is assigned an interface via the "Link" tab in the Pro!>"rt;" s window of a Send 1M (select module and EDIT -+ OS/ECT PROPERTlI:S).
The llmonscment of distributed 1,0 stations is ckseribed in Chapter 20.4 "Communication ~ia Distributed 110".
2.J.2
AddTf'Mlne. Module.
When ammging modules. the Hardware Configuration tool automatically assips a module ~tart address. You can view this addn::ss in the lower half of the stalion window in the object
Then:: are modu les that have both inputs "nd outpUtS for which you enn (thwn.:t ically) reserve different start addresses. Howc~cr. ple~ note carefully the spec ial information pro~idcd in the product manuals; the large majority offunct:ion and communications modules n::quin:: tbc same start address for inputs and outputs. When assigning the module Still address on the 57-400, you can also make the USii"TnCDt \0 a subsidiary process image. If there i. more than nne CPU in Ihe central I'llck. multiprocessor mode i. automati cally ~et and you must assign the module to a CPU . With VTEw -+ ADDRr.SS OV IlIl.VtllW. you get a window containing all the module ~ddres,cs currently in us., fOT the CPU !eleeted. Modules on the MP[ bus or eommunicalions bus ha"e anMPI addn:s~. You may also change this address. Note. howe,·.,r, that the neW MP! addre .. b«ornes effective as $OOTI as the oonfiguration data are transf=ed to the CPU. Symbols for USCr d ata add F"flSCS [0 the Hardw,.,-e Cnnfigul'llllon 1001, you o;:a.n ItSsign to the input. and outputS symools (name.) th.t an:: transferred to the Symbol Table.
After you have arranged and addressed the digitsl and analog modulu, you save the station data. Then you >clect th~ module (line) and EDIT -+ SYMBOLS. In tlte window that !hen OpenS, you <:an assign a symbol. a data type ami a OOmm=t to the absolute address for each channel (bit-by-hil foc digital modules and word-by-woo-d for analog modules). The "Add Symbol"" button enten the absolute addresses as symbols in piKe of the &I»olute address" without symbols. The MApply" bu!ton trans fers the .ymools inlO the Symbol Tablc . "OK"' also closes the dialo& box.
2.3 Configuring Stauon. 2.3.3
I'n. m ~terldnlt
Modul""
When you p8!"lUTlCCleritt a module. you define ilS propen;H. It is necc"",ry to parnmeleriu a module only whcn you Want to change Ihe default parameters. A requirement for parametcriution is thatlhe module is I<)<;at...:! in a configumtioo t.able. Double-did; on the module in the <,;onfigl.lTlllion table or !le1ccttbc module Bnd then EDlT-+ OIlJECT PROPERTIES. Several tabs with tht ~pecifiable parameters for this module are displayed in the dialog box. W~n you use Ihis metbod 10 paramCleri7.e a CPU. you arc ,pecitying lite run characteristics of )'Our uSet" pro-
,= .
Some modules allow)'ou to liet their parameters at runtime da tile U5Cr prolj:nuJ1 with the system functions (5« Chapter 22.S.2 "System Blocks f.,.. Module Parametcri:vmon").
their MPI addtnscs. If you do nol want to assiJl11 a name yourself. you can, for
!.3.~
2.3.4
Networking Mndules wllhMPI
You define the nodes for the MP! snbsidiary (su.lmcl) with the Module Propenics. Selectlhe
CPU. or the MPI interlace card if the CPU il equipped wilh nne. in Ihe confIguration table and open it wi!h EDIT -+ OIlJECT PROrERTlF~. The dialog box thai then appc= containli the "Propenics" button in the "Interfacc" box orthe "General" \.lib. If you dicit 00 Ih .. button yoo arc I8k~n to another dialog bo~ with a "PPrtlmt ter" tab where you can find Ihe suitable ~ubnet . Th is i$ al so an opponunity to ,et the MPI address lhal you have provided for this CPU. Please nole that on older S7-300 CPUs. FMs or CPs wilh MP! eOOrICCllOO automatically receivc an MI'l addres. derived from the CPU. The highest MPI address mUSt be grealer than or <.-qualto Ille highest hlP! address usignc<.l in the subnel (take accounl of automatic as .. ,n· ment ofF~b and CPs!). II must have the same value for all nodes in the subm1. Tip: if you hav
i\l cmitorinlil and Modifying
l\tudul~
Wilh the Hardware ConfigUntlion , you Can carry o ut a wiring checK of the macbine or 1'1"", ,,';thOUI the u,er progntm. A fC"qum.mcnt for this is that the programming device is con"ecl...:! (0 • st.alion (mime) and Ihe configuration h~~ be~n saved. ~ompiled and loaded inlo the CPU. Now you can nddrcss every digilal and analog module. Select a module Rnd then plC -+ MONITOR/MODIfY. andsetlhe Monitor and Modify opentting modes and Ihe trigger eondll;ons. Wilh Ihe "'Status Value" bUllon . the Hardware Configura!iQII shows you the signal stales or the values o f the module channels. The "Modify Value" buttoo ",ritcs the value specified ;n the Modify V.lue column 10 tlH: module. If t~e "'110 Display" chl'CKbox is active, the peripheral inputs/output. (modu le memory) are disp layed instead ofthe i"puts/outputs (process image). "The "Enable p~Tlph. Outputs" chl'Ckbox revoke. !he OUtpUl d..able of the outpul modules If tbe CPU !I in STOP mode (see Chapter 2.7.5 "Enablinl! P""";pheral Outputs"). You can find olher methods of monitorinl! and modifying inputs and Qutpuli in Chapters 2.7.3 ·'l\.1Q11iloring "nd Modifying Variables" and 2.7.4 "Forcing Variables".
"
I
2 STEP 1
2.4
Pro~1IlIIlinB
Software
Confil:urlng Ihe :'Iiet".-ork
ba~it ror ~onununicalion, ,,';!h S1MAT1C is the nc:tw9r1
The
wit h the S IMAT tC Manager within the project biuBrc hy. You (hen add the modules with communications capability (CPU. and CPs) USing the Hardwa~ Configuration 1001; at the same lime. you I15sign the communication, interfaces of these modules to a subnet. You Ihen define the communications relatioRJIbips bnw«o these module, theconnedions - wilh the Network Configuration 1001 in the connection lable. The Network Configuration tool allows graphical representation and documentation of lhe CQn fiillrcd networks and \heir nooe" You can
also croate all !I(X;cssary ,ubnets and stalions wi lh the Network Configuration tool; then you nS3 ign th e stati ons to the subncts and pdr~mc' teri7C Lhe node propenies of Ibe modules with communications capability, You can proceed as folio.,...,. to define the com· nllmications relationships via Ihe networkina confi&uration tool:
NETWORK --> SAVE "''<'5 an incomplete Net""ork Configuration. You can cheek the con!isteney of a Network Configun.tion with NET· WORK --> CONSISTE..'-JCY CUECK, You c1~ the Network Configuratioo with NETWORK --> SA VI! A."D COMPIlE. !'Jdwor k window To start the Network COnfiaUrtllion, you must have create d a project. Toa;etber with Ihe project, the 51l\IATIC Manlger automatically creates an MPI .subncl. A double-click on thi5 or anyOlher subnet staru th.e Network Configunlion. You can also reach the Net,,'Ork Configuration ir you open the Connectioru object in the C I' U container.
In the upper section, the NetwoO: Con figun.. tlon window shows all previously Cf¢ated ~ub nets and stations (nodes) in the project with the configur~d connections (Figure 2.5) , The cOIU'e<: !ion table is displayed ;n the lower sec tion oflhe window if n module with "communicalionscapabilityH, e.g. an 57-400 CPU, i5 selected in the upper section of the window. A second window displays the network object
ca"log with a selection of the available S!)-lATiC §lations, subnets and DP stations. You can rade the catalog in and out with Vlf'w -+ CATALOG and you can "dock'" it onlO the ri&ht edge of tbe network wLOOow(double·dick on the title bar). With VIEw _ ZOOM II", VII,,,, ..... ZooM O UT and VlliW _ ZOO:.t f ACTOR .... you ca'l adjust the clarity of tile graphical representat;on,
f>
Open the M I'l subnet created 11$ scandard in the projCCt cootaincr (ifit is DO Innaer IvailIble, 8imply create a ne'" suhnet willI 1l"5ERT _ SUII:>CIET).
c>
Use the :-"elwo"" Configuration 1001 to C~ ate the necessary . talions and - if required funher sl.lbnets.
po
Open the station. and provide them with Ihe modules with commun icalion! capability.
2.4.1
po
Connect the modules with the relevanl subnelS.
StI~cIIO I:
I>
Adapt the ne\Work parame1C1"!1. if D«eIBry.
c>
Oefine the commuoication connections in Ihe connection lable, ifrequiTed.
You can .lso configure global data communications wilhin the Net ....ork Configu"'tion: $Clect the MPI liubnet and then r.ele<:t Opno:-;s ... O~ft:-'I! Gl.olIAl DATA (see Chpter 20,j"Global Data Communication").
Configuring th e ,,",f two rk lind
arran glnlllh~
VI~w
(omponentl
You begin the ~etwork Configuration by nlectina; I suboel that you selftl in the cataloa; ,,·;tb the mouse, hold and draa; to the network window. The suboel is represented in the win· dow as II bnrizontal line. Impermissible polIi_ tions are mdicatcd wilb II "prohibitcd" sign on Ibe moUse pointer. You proceed in the !>ame way fOf th~ d~sireG stat ions. at fi !"$1 without connect.on to the sub-
.,
.. . r:=0i-:. i ;;;;;;' • '..-.. · .. ...........
lor ... .. .,. m ",-
,-
.
••
-\""
".....
•
..... . ... ...... -0
-';;' ''.1._
.. "' "
..l _~ "
. .J _
.
.
•
net. Tbe stations arc ,till "empty" , A doubl~ elicit un a stallOD opens the Hardware Configu· ratinn tool allowinll you to configure 1lI0 SIIUon or a1 least the module(s) with nelwurk conn~c lioD. Save the station and rerum In the Net ..... ork Configuration_
Th e interface of a module .... ith communi.:a[;Olu; ~apabil;!y is represemed in the Nem'orl< Confiaur;r.lion as a small box undcr the module vicw, Click on this box, hold and dlllg ill<) the ...,!evaot subneL The conncction In the saboel is
-.
•
"• :::11'_ " · --''' ...1<'_ -, -",,,,,,,
--
· . .1 -""''''' . . >'0 J _
>-
is=-
•
represemcd as ... ,·erticall ine. p~
......
in exactly the s.ame way wilh aU other
You Can move cnated subnels and S!arions in the network window. Tn this way, >'00 ean al..,
represent your hardware cun figu!'\Ition visually_ Under cenain cin:wrutances. you itl a clea ...... and ~ con.paCl ImmgC11l<'nt If you t't'duce reprosc me"ET tl:.....Gnts.
S.-n ina; cO nlrnllniu lion. propenies A nOT C"'3.;n8 th~ graphic~1 view. you parame· terize the 'lIbnel>: select the subne~ and then EDIT ..... OBJECT PROPERTIES . The properties
window that then appcan; indudes Ihe S7 ~ub· net 10 in the "GenenoJ" tab. The !D consislS of IwO hexadedllllli numbers. the project number and Ihe ,ubn~1 number. You n:quin: th is S7 ~ub net 10 if YOIl Want \0 go online wnh the pro~rnmmmg device" "hout • suitable projecl in omer to reach other nodes via the subne!. You set the netv.'orlr; propct1;C$ in the "Network Set· linlfl"lab. e.g. the data transfer m lc Or the high· est node addr<."is. When y"u s"I<:<:1 Ibe network connection of a tlo
2 STEP 7 prognomming Softw.,..,
communications capability. wilh Ihc nodc addresses and the subnel types US4..t You define !he moduk properties of the node!o in I similar way (with the same operalor inputs D.S in the I r ard"'~re Configuratiun 1001).
2.4.2
ConfigurIng alli>clribu led 110 wltll fhe Network ConfiguratIon
You can only connect an intelligent OP ,lave to a suboct if you bav~ previously en::nled it (see Cllapler 20.4.2 "Configuring PROFlHUS OP"). In Ihe n~...rk object catalog. you can find the type of imel1iilcnt 01' IiIn,"C under "A lready created slations··; drug it. with the OP master sclcct~d. to the network window and fill out the properties windOW that then uppcnl"'l (as in the Hardware Configuratiol1toolj.
You can aloo use the Network Conligur~lion to) configun: the distributed 1/0 with PROF"rRUS OP or PROFNET 10. Sclcrt VlEw ..... WITH DP SLJ\vLVl O D £vrclOs 10 display or Iilde 01.11 Oi> slaves and 10 devicC"S in the neN"Ork view.
Wi!h VIEW ..... 111G11I. JOIlT ..... YfA~Tr.R SYS"nM. you emphasize the assignment of the node. ofa Df' master system; l1rst, you ulcel the master or II slave o[this master system. With VltW ..... REJ\RR~""GE, the OP slavcs life a!<5igned optically to their OP mast~.....
PROF'IBUS OP
I-'ROHNl:T 10
You require the follow,ng in ullier to configure a OP maRter ~y.tem :
In order to configure a PROF INET 10 ~YMcm. yuu reqUIre :
I>
i\ PROFIBUS subnel (i f not already avuil-
Kblc, drug th~ PROFlBUS subn~t frotn Ihe nelwurk ubjed ~atalog to the network window), I>
A Dj> m"stcr in a stalion (if nOI aJrclldy available. drag thc stalion from Ihc nctwork object ealalog 10 the network window. open the 51ation and select a DP master wilb the HardWllre Configuration 1001, either inlegr.lled in the CPU or 8.. an autonomous mooule).
I>
The:
<;OfIn~"Ction from the OP mastcr to the PROFmuS suhnet (~ithcr select the subnct in Ihe Hardwan:: Configuratiun 1001 or ehek on the network connection lU!he OP ma.
In Ihe network window, seleC1 the Dr ma!Oter 10 whicll Ihe dave is 10 ~ assigned. find the OP sllOve in the network object calalog under "P ROFmUS UP" and the relevant suiH>lItlilog. d!":lg it to the network window and fill 01.11 the propcnies window thaI "ppea",. Yo u panuneteru:e the 01' slave by ~~I~C1iDg it and then !lel~cting J:;J)fT ..... OrEN OBJECT. Th~ Hardwanl Configunuion is started. Now you can ~et the user data addresses or. in the case of modular lilaves. select the lIO modules (~e Chnpter 2.3 "Contiguring Stat ions··).
"
I>
An Industrial Ethernet subnet (i f not already available. drag Ihe Industri al Ethcrnet subnct from the network object catalog to Ihe nctwork window)
~
An [0 controller in a sllItion (if not already available, drag the stalion from the netwOTk obj~"Ct catalog to the network window. opctl the station. and .'I¢I~t lID 10 controller with Ihe Hardware ConCigurnlion 1001. either intcgrated in the CPl: or liS nn autonomous module)
I>
The connC<:tion from thc 10 controller to the Industrial Fth~=et subncI (either already selccl the 'UbnCI in the lIardware Configuration 1001. or click un the nerv.'or\( eonnec_ lion 10 the 10 contruller in the Network Configuralion, "hold" und drag 10 the Indus_ tria l Ethernet network
In the nClwurk window, SCkct the J() controller 10 which the 10 device ;$ to be assigned. Find Ihe 10 de,'ice in !he network obje<.:t catalog under ··PROFi}.'ET 10" and the relennl .ub-
catalog. drag it to the network window and fi ll out the properties window that appears. You parameterizc the 10 device by selecting it and then selecting EDIT ..... Opo; OIlJECT. The HndwlU"C Configuratiun ;$ staned. Now you can ""I the user data tt<.ldresse~ or the 1/ 0 modules (sec Chapter 2.3 "Confi guring Station.").
2.4 Configuring the Network With VIEW ---> Hl(.ID.1GHT ---> PROFiNET 10 5\'STL\1. you emphasize the assignment of the nodes of a PROFINET 10 system; rUSt, you select the 10 controller or an 10 devic~, \Vith VlliW ---> REARRA:-';C,E, the 10 devices are assigned optically to their 10 controller.
2.4.3
Co nti,"u ring Connecnons
Connections describe the communicati(ms rdation,hips between m'o devices . Connection.' must be configured if "' you wam to establish S7 communkations bem'een two SIMATlC S7 d~v i ccs ("Com· munication via configur~d connections'') or t>
the communications SI"'lATlC 57 device ,
panner
i,
not
a
Note: you do not require a configured connection for di",ct online conncc tion of a programming device to the MPI network for program ming Or debugging. Jf you wam to reach oth", nodcs arranged in O!her conne<:ted subnet' w ith the programming device, you mu~t configure th e cotlllcction of the programming device: in the Network Object Catalog. sdcct the PGIPC object undcr Stations by double · cl icki ng, open PGIPC in the network window by double· clicking. and ,eleclthe intcrface and assign it 10 a .ubnet, Conn~"t lon tabl~
The commnnications connUlioru; arC config· ured in the cotlllection tahle. Requin:mcnt : you have creat~d a project with all ,lations thai are to exchange dam with each other, and YOll have ,"s igned Ihe module. with commun ications capability 10 a ,ubtlet, Thc object Connecrio",,' in the CPU containcr repre,ents the connection lable. A double·click on Connections starts the Nem'ork Configura-
Tabt e 2.1 Conneclion Table Example P~rtners
tion in the Same way as a double-click on a subnet;n the project con~,incr , To configure the conncction" select e .g. an S7400 CP U in the Nem'ork Contigurm ion , In thc \0"('1' section of the nem'ork w indow, you get the connection table (Table 2, I: ifit is not visi ble, place the mouSe pointer on the lowcr cdge of the "'i ndow until it changos sbapc and then drag the w indow edge up), You enter a new communication connection with \r-;SERT ---> KI\\' CON"E.'IO:-'; or by double -clicking on an empty line . You cre3l~ a connection for each "active·· CPU. Please note that you cannot creatc a connection table for an S7-300 CPU; 57-.100 CPUs can otlly be "passive" panncrs in an 57 connection, In the "'New Cotlllection" window, you selcct tbe eommunkation~ partner ;tl 'he "Station" and "Modulc"' dialog boxcs (Figure 2.6); the .Italion and th e module mu~t already exist. You also detennine the connection type in tbis window. If you want to Set more connection properties, activate the cheek 00" "Before inserting' disp lay propenies". The connection table contains all data of the configured connections, To be able to display this clearly, usc V IEW ---> 0l'TlMT7 F COLlJM"I WIDTII and VIEW ---> DISPLAY COl=S and select the information you arc interested in. ConnectIon
[l)
The nnmber of possiblc connections is CPU· 'pecific, STEP 7 define, a connection 10 for every eOtlllection and for every partner. You require this ~pecificatioll when you u,c communications b locks in your program. You ean modify the 10CQIID (the connection ID of the currently opencd module). This is nece,-
.ary if you have a lready programmed commu· n icali on < blocks and you want to u
Value
rang~
for S7 connections:
00011><, to OFPP h<., t>
Value rang~ for S7 connections with load· able S7 communications (S7-300) : 0001"". to 008F hex
f>
Valuc range for PIP connection>: 10rxlt,., to 1400 he ,
You cbange the partner II) by going to the ~on nection table of the partner CPU and changing (what is then) the local 10: sel~""t lhe conne ction line and then EDIT ..... OBJECT PROP 5RTlIS If STEP 7 does nOl enter a partner TO, it is a one-way connection (sec below) .
.. IJ
-
Partne,.,. lbis column disp lays the connection partner. If you want to re>crvc a connection resource without naming a panncr device . ~"Ilter ··"nspedfied" in the dialog box u nder Station In a on e-way connectlun. "ornmunkation can only be initiated from one partner; ~x ,unple : S7 conmmnication. between an S7-400 and S7300 CPU. Even without S7 communications function, 1n the S7-300-CPU, data can be exchanged by an S7_400 CPU with SFB 14 GET and SPB 15 PUT. In the S7_300, no user program run. for this communication but the data c.~chan;;e is handled by th. operati ng <;ys-
"m
A one-way connection is configured in the connection table of the "active'" CPU Only the n does STEP 7 a.;;ign a "Lo~allD·· . You also loa d this c0nne~tion only in the local station. Wi th a two_way cunn~ction, both partners Can asS lmle communicat ion actively: e.g. two S7400 CPU s with the comnmnication,; functions SFB 8 SE:'>ID and SFB 9 BRCV.
2.4 Confi!! .... ring the Networi< Vou configure a TWo-way connection only once for one of the IWO panners. STEP 7 then assigns a "LocaIIO" and a "Panner 10" and vcncno1c.l the conneetion data for both staUon~. You mu~t load each ""nncr " ';Ih ils own cOMection table. Co"n« lion lype The ST EP 7 BlI!l;c Package provides you "'ilh the following connc.:t;on f)-pcs;n Ihe Net"ork Configuration: PIP connc.:! lu n. approved for Ihe ~ubnel PTP (J964(R) and RK 512 procedures) with S7 communicalion~. A PIP (poinl-to-point) eODneclion i. a $Crial conneclion belween IWO I"'nne"'_ These can be IWO S IMATIC 57 device~ wilh Ihe relevllnt lDleTface! or CPs. or a SIMATI C 57 device Imd a non-Siemens devicc. e.g. It printer or a barcode rcadCT.
57 connectlon , approved for Ihe s. . bne\s MPI. PROFIB U5 and Industrin l Etllenlel Wilh S7 communic ation. All 57 conneClion is the connIXlioll between SIMAT IC S7 dcvices and call include pro!;l"'lmming devices and human machine inlerface devices, Datil arc exchallged via Ihe S7 "ollllection, or progl1lmming amI control functions arc ex....:uted. F.ult_tol .. ranl 57 ~on n eellon . approved for the subn~1s PRO Fl J:jUS and Industrial Ethernet wilh 57 communication s. A fault-toleTant 57 eOM IXtion ;$ mllde betw«n fauh-Ioleram S IMATIC 57 devices and il can also be utablishM 10 an appropriately equ.pped PC. The software componenl "51MATIC NC~l", which is pari of STEP 7. ;5 a\,II;I.ble for p .... m<'le riz[n¥ C Ps. Vou have conneclion types available for selection: fMS eonn"":lion. FOL eonllection. ISO Inln~pon eonneClion, ISO-on- Tel' "oMection. TCP eonneclion_ UO P connection and I'-maii "onn"":lion. AClive
con n~e!ion
bu il du p
I'rior 10 the actual data transfer. Ih" eonneclion m LlS' be buill up (initialized). Iflhc con nection pann~rs have thi~ capability. you specifY here w hich device is 10 eSlabl;~ h th" conneclion. Vou do this wilh the check box "E~.abl; sh an aCI;ve conneclion" in Ih" properties window o f Ihe conn~""lioll (select the connection and thcll EDIT ~ Gilmer PROPIlRTlFS).
S"ndlnlil operu!n!: n. l"
me~.a lilrs
ConnlXlion ""nne", wilh a configured twOw"Y cOMterion can exclumge operating ~Iate messages. Iflhe local nO
TUS. Con ne ctio n pa lh As th~ connecl;on palh •• hc propenie~ window ofm~
COMIXlion displays the end points oflhe connection and me subnets ov~r which Ihe oonnect;on runS. If mere are sevet1l1 5ubnet~ for Sdeclion. 5TEP 7 selects Ihem in Ihe o rder Industrial Ethernel belo«' Indust,;al Ethernet! TCP-ll' before MPI before I'ROFJllUS.
The stalion and the CPU ovCr which the con· nCClion runs are displayed as the e tld points of Ih e connlXlion T he modules wilh communica_ lions capability are listed under ··Interface··. specifying Ihe rack number ""d the sIN. lfboth CPUs are located ill the same rnck (e.g. 57-400 CPU. in multiprocessor mode), Ihc display box shows "PLC-intemal". Vou will Ih~n sec the MPI add«,u or PROF Inus address of the node: ullder "SubnCI" and ··,\ddrcss·. Cu nn« t loo5
b~tween
proj e<:u
For dina c"(change belween tWO 57 modul..,~ belonging 10 difTCTCIlI 5IMATIC projects. you enlC" ,m~peeified" for connection panner in Ihe conneclion table (in me local stalion in both projects). I' lea"" ensure Ihal Ihc eonneclion data ag«'c in bolh projects (STEP 7 docs not (:heck .his). After ""ving and (:ompiling. you luad Ihe COnnection dina inlo Ihe local stalion in el1l; h project.
If a project is 10 subsequently become pan ofa mulliprojeCI. snd if .he connection panncr is also within a projecl oflhe multiprojcct. select "In unl<1lown proj ect"' as the c,,"nectio" panncr. and enter an ullambiguous eom' cel;OIl name (reference) ill the propeni"5 window.
"
2 STEP 7 Progranuning Software
Connection to n on-S1 st ations Within a project, you can also speeiry stati ons other than S 7 stations as connection partners: I>
Oth~,. Slation, (non-Siemens device, and also S7 stati ons in anom ...,. project)
I>
Programmi ng devices/PC.
I>
SIMATIC S5 station,
A rt:qtrircm<:m for configuring the conne ction i, that the non-S 7 station exists as an obje~t in the proj ect container an d you have connectcd the non-S7 station to the ",levant subnet in the ,tarion properties (e ,g. select the station in the Network Con figuration, sdect Eun --. O!lJElT PROPIiRTlFS and COtlllect the station with the desircd subnet on the "Interfaces" tab)
2.4.4
G8tew.y~
If the programmmg dcvi~c is ~onnected 10 a
If you want to re"ch allnodcs in a subnet with a programming dcvice from One connection point . you must configun.: the comlection point, You etller a '-placeholder", a PG/PC station rrom the Network Objc~t Catalog in th e network contiguration at the relevant subne!. YOl< contigu", a PG/PC station on every subn~.., to whi ch you want to ~onnCCI a programming devic e. During operation , you connect the programming d~vice to the subn~1 and .dect PLC --.
ASSIGN PG/PC. This aJarlS the interfaces of the programming device to the conftgured settings for the subne!. Before disconne c1ing thc programm ing device again from the subncl, select PLC --. CA"S"CEL l'G/PC AsslU~"
If you go online with a programming device th"t doe s nO! contain the right project. you require the S7 ,ubnet ID for network acee". The S7 subnet IV ~()mprises "'m numbers: Ihc pT<>ject nllm lK'T an d the subnetnllmber. Y,m can ohtain th e OIlJECT PROPERTIES on I he "Gencra1" tah.
1.4.5
Loading th~ Connection Data
To activate the c"nncctions, you must load the conncction lable into the PLC following saving and compiling (all connection ta bles into all ·'active'" CPUs) , Requiremelll: Yon are in Ihc network wi ndow and Ihe connection table is visible , The prograrruning device is a t\Ode or the s uhnet over which the connection data arc 10 be loaded into Ihc modu les with conununication. capability, All subnct nodes have been assigned unique node addr~sscs. The modules to which connection data are to be transrem.:d arc in thc STOP mode. With PLC ---> Oov.'}.'LOAVTOCURRENT PROJECT ---> . ,, ' you transfer the <:onncction and configuralion data 10 thc accessible modules. Depen ding on which ohjeci is sc1~ctcd and which m enu conunand is sel«ted. you ~an ~hoosc between the following ---> SIoLIClloU STATIONS
--->
SELIoCTED AND PART'
--->
S TATIONS 01\- TI lE SUH""ET
--. S ElECTED CO"'N"lTTIONS --. CONNECTIONS AND
GATEWAYS
In order to delete all connections of a programmahle module. load an empty connection lab le into Ihe as
2.4 O m figuring the Network
tmnsf<.-n th .... Cf>nnecti on data to the mod ules ",ith communica tions capability_ F or online operation via iYfP L a programm"'g dtwi~c r~ql1lre~ no additional h ardware . If you ~onneet a PC to a network Or if you connec t a p rogramming device to an Ethernet o r PROFl_ B U S network, you require th .... relevant int.... rFace module. You parameterize the module w ilh the appli cation " Sening the PGIPC Interfa~c" in th e \Vindows Control Panel.
2 .4.6
-"la t ching ['roj ect . In a l\ l ultlprojec t
Wben opening a multiproject with the Network Conligurat ion tool, a window is displayed with the projec15 present in the muJt iprojcct. You a l,o o btain this window i f you open a projec t included in a multiprojcct and select VlE\\ ----> MIILTlPROJE<:'"T. The window d i"play< the
p rojects present in the mu lti p roject and thc cro,-,-projcct subnets which have a lr.... ady ~n combined , Select a project for flmher pr<><:essing by double d ick in., (Fig"rc 2,7) _ Proj ects usually contain communications con nec tions between thc in dividual statio ns. If projects are combined into " muJtiproj~et, or if Hn e.~ istiI\g prujcd is indudtd inUl the mult i~ proj ect . these connections c all be combincd a nd matched If you ,eket VlloW ----> CROSS-PROJECT NETWORK VIEW in an opened project that belongs 10 a multiprojcet, you will see an overview of a ll stations ofthe mu ltiproject and the current connections. In th e cross-project network view. yon cannot make any change, to the projec ts. Sckc·ting VIEW ----t CROSS-PROJECT NETWOR K VIEW " g a in exits the multi proj ect vicw.
... ::!iiI'"'" """"-, , ...., l:..boJ"
,..'" i '''---''''
t·""", ...... ,,_~""
c.""",,,, ,..."-"",,
L"",-, __'..M_""" cv·..... ""'·~".
8'""""""""_
,I M_ ~
.r-.
F ig u c. 2. 7 Mu l1 iproje
!fu. __
{_
"It:m:\)
tw ,,,e, Of'
3-1
1" __
-
I
...:.~.J. __ t,
2 STEP 7 PToiramming Software 5 uhne t~
Com bining
The MPI. PROFIRUS and IndusniBI Ethernet subnelSarc combined togelhcr first. A p=<'qui.ilc ill that the subnel8 10 be combino:d ha,'e the same subnel 10. Wim the subtlel seleclo:d. you can set thcse in the Network Configuration tool using EmT ~ OllmCT PKOPERT!£S. With F ILl; ~ MUU1PROJECT ~ ADJUST PROJECTS you CDn ClIlI 8 wi""ro fDr mn open multiproject in the S IMATIC Ma".ger which supporn you wMn matcbing. In the N~'1,.-ork Configurntion fool. you obtain the dialoi win_ dow with EDIT ~ MERGF.Jut.,'MERGJ; SLfJ"ETWORKS
~
...
You ,elect the type of subnet. ~\ick the ··Exe· cutc" bulton. and obtain the suOOe" of the selected l)lpe "",:>ent in the multiproje.:t. You can now select indIvidual suOOe!' of~ projects. and combine in U CTOIIs-pmject suboet. You CIIlI use tbe same dialog 10 eliminate sublWts from the ero&~-pmje<..'1 sub""l. Several cross-project .ubnc13 of the same type can be created in ~ multiproject. The properties of the cro»-project sulme! arc ru.'1ennined by the fint .u~t added or by thc subnet sdecto:d wilh the "Select" bullon. Use ~OK" or-Applyto acknow'tcdie the ""nings_ Subnct$ ..... h,ch are pan ofa cross-projCCt .ubne! B~ idenlifie
~unn~~tlon .
The connC<'tions configurt"
ners. Select EDtT ~ M ~RGE CONNECftONS to oblB;n a dialog box with all configured eonnections. SelecI One connection in each oftbc Window$ "Connections .....11hout conne<:lion part_ ner" and "Possible connection partners" and cltck "Assign". The aMigned coonections a~ li.lted in the bonum window "Assigned conncelions" . Use "MCl"ic" 10 then combine the Con_ nections. The cOOllections arc assigned the properties of the I<)<:al mooule of the current ly opened project. You ean mooity thc connection properties wben combintng. Con ngu rl ng croS5- projt<:t eonnectio ns Followi ng the combinalion o f ",bnet~. crossproject conn~-Clions can be confi gured . The proeo:durc ;s the SIIITIe PS for project_inlernal con_ n.,.,.-tion$" extcndo:d by specification of tbe: project atllie connection panner. You can tcst a nct ..... ork configurati on in the m~ltiprojec l for comrn
2.S 2.5.1
C r ealing th e S 7 P rogram IntrOdu ctin n
The U.'ICt program is crealed under the object S7 Progrom_ You ean flS.!:ii" this ohjecl in lhe
projecl blerarchy ofa CPU or you CBlt c~atc it iDltcpendently of a CPU. It conlllins the object S)""'/><)/5 and Ih~ containcrs SOI
With Ine ri'm ental program crealion, you ~nt~r th c program d ir~et block-by-block. t:nnies are checked im tncdimely fOT synta;>t. At the same time. the block is compiled as ;t is saved and lhen slo~d in the containCT Blocks. With incrcmenta! programming. you can alS() ~dit blocks online in the CPU. even during operation. I IlC~mCl1tal programming is P' e:'oo (address priority) ,
2.5.2 S)' mbol'h ble In Ihe control program, you work with addresses; Ih<:• ., ....e inputs, outpUIS. limcrs, bl ocks. You cao assign absolUle addresses (e.g. 11.0) or symbolic addr~,scs (e,g. Start signal). Symbolic adJn; , sinl! usc. nameS instead of the ftbsolutc address. You c.n mmke your program euier to n:ad by using meaninaful names In symbolic addressing. a dIstinction is made between local symbols and Jlluhul ~ymbo1<. A local symbol i. known only in the block in which it bas been d.,fined. Youcan u.-.c the same local .ymbol' in different block .• for different purposcs . A global symbol is known through_
out Ihe enlin; progrtlm and has the Same ",,"an_ ing in.11 blocks. You deline global symbols in the symbol table (obj ~cl Sy",I,,,I.• in the contain<''1"S7 Program). A gloNI symbol starts with an alpha chm"cte, and can be up to 24 characters lona:. A global symbol cBn also comain splICes. spcci.d chame_ ICTII and narional characters such as the umlaut. Exce ptioru; to this an: the characters oo...,A. FF""Aand the inverted commas ("). You must enclose symbols w ith special charaete", in invened commas when proafa1l1ming , In Ihe compiled block, the program edilor d isplays all global ~ymbols in inverted commas. The symbol cOmment can ~ up to 80 churnetcrs long ,
In the symbol table you can assign RPm"" to the following a
lnplns I, OUtpUIS Q, pcnpheral inpulll PI and pcriphCT1l1 outpulS PQ
to
Memory hits M. t,mef funclio"" T and coumer functions C
to
Code blocks OU~, FBs. FCs. SfCs. SFTh and dam blocks DBs
to
User data types UDn
;>
Vanable table VAT
DaTa addresses in the data blocks are included amonll the local " ddresse~: the 8ti.1OCi",ed symbols are defined in the dcelHrolion $<.."<:tion of the data block in 'he case of 1I1obat dnm blocks Hnd in thc declaration sec lion of tile function block in the case of instance datil btoc~$. When creating an S7 Pro¥flUll, the SIMATIC Manager also cr.;:alCS an empty symbol table 5)71,bols, YOll open this and can then deline the atobal symbols and assign them 10 absolute addresses (t'igure 2.9). Tho:n: e~n be only one singl~ symbol table in an 57 program. The dUla type i8 part of the deli
"
2 ST IiJ> 1 J>rogrammi.ng Soil ...."""
"" "" "
"" "" ""
"N "N 0
"" "
~'''' """""" .. Io, PO_
..."""'''''1[ ....,,......,
,"
'.J ' .1
"" ....,.""l
II.-
~ ..
'...- ..
,_,od
'00. r.. " ....... ,at .,...",
La ....... " " ".... t ..
R...... ,.10 '''''' ....
.....".
~,
~
~ ~ ~ ~
.. n
With incremental programming. you ~f~ale the 1<)'mbol lable b~fo", .,m.,ring th~ prugrum; you call DIS!) ,dd or COlT<:<:t individual symbols dur· illg rrovam illput, III the ca•.,. of source-ori· <,:med programm ing, th ~ complete .ymbol table ",u~1 be IVlilable w h..., th~ prognun &OlIree IS ,"""opi lcd.
Impu rtlni,:, Hportlng Symbc l t"bles can be imported and cX",,"cd. " Export ed'· m~all!< a file is ~reated wi III th~ con· 1ent~ o f your symbollab le. You can ""I~~t here either the ~ntire symbcl table. a rub ..."! hmit~ by filters or only selected line,_ For the dma for· m it you cau ehno~ be-iwtttl pun: ASC II 161 (exumtton ' .88C), $C'quc-nlial a>..ignmenl lisl (*.S4"<1), SYbll;m 1l1"~ Fomtat ( · .~f for Mierowft AC(:Css) ~n
72
Sprd a l obj <'t'l propertie. Wilh ~DlT ..... SI'ECIAL ORl~T PROl'fRTtES .....
..• you ,..,t atlributcs for each symbol in the symbol cabl.,. The
I>
Httman mach in ~ inlerface monitoring wilh WinCe
fuTlclion~
I>
Configuring-me"agc~
po
Configuring commun;ClI.ti<>TI~ NCM software
po
Control al contact ",-ith inputs aDd bit memori~s in the program ed,tOr
usin.:
for
lhe
\lrf:n' -+ COLUl-INS R , 0, M. C, CC males lhc settU:lI.' ,·!sible_ Witb OntONS -+ CI:l'OmMrl.!;, you can ,.-pecity ,..heth<-"!" ()(" nut the special object properties are to be copied und you ean define heh"v;orwbcn importing ~ymbol~.
1.5.3
r ......gnun
t~d ltor
iO<,.....,lJ1ental programming; however, you can enter new symbo ls or change symbols during pn>!lnlm input.
For ~"'Rtjng the user pro&"Pnl. the SHoP 7 I3nsic P""kagecontains a progmm ed itor tor the LAD. FA D and STL pmgrammin& language •. You program incrementally wuh LIID and FDD . Wt i~, you eoter an e~ecutable block di ........,t; Figure 2.10 shows Ihe possihle "Clions ror this. If you usc .ymbolie add~sing foc global .ddreS1e~. the symbol' ,mill already Ix: .. ~si8ned to "n absolute address io the case of
LAD 'FBD bloch can be ··decompih,d··, Le. a relldable block can be c""at~'U again from the Me7 code without an oftlioc database (you can read any block from a CPU using a prognommina device without the asso.:;ated project). In ...!diuon. an STL proglllm sou",,, ~&n be ereal~d from any compiled block .
I ~ .------------',,,,"",,,,'"""",, '",•. Source
..
."'
O1fttne
r ----"""'''''".':)
Import "x,-mal SOuroo
~ InBlocI
programming
Ontlne
FI~ur~
L__
'~!.=~ ::o:)
1.10 Writing rftlirorn! " t!h the I-A[)fHl[) Ed",.>,.
BlodCs
I
~
2 STEP 1 t>rogramming Software SCMr1lng t he program editor y"" reach ,he program ~ditor whom Y"" open a block in the SIMATIC Manag~r, ~ .&. byoouble· clickin!! un the Mutomatically generated symbol orth~ Oraaoi7.8tioo block OR I, Ot via tbe Will· dows 'Dskbar with START --> STM"'l"IC - I STEP 7 --> LAD. STL. FBD - PROGRAMMINU S7 BLOCKS.
You can customi:z~ th~ prol"'nje~ or the program editor with OJ'nONS --> CUSTOMl7F.. On th ~ "&ii,or" lah. >!CicCI thc prupcnies with which a new block is 10 be g~nerat«l and di .... played. ~...,h liS the ~"T<:ation langullge. pres<:lcction for commeots, aod symbols.
The Ol'<"vi<'",s winduw Shows the pro~..,.am ele. ments and Ihe call structure. If;1 is nOI visible. display il on the screen u.ing VIEW --> OVER. VIEWS.
The Details window can be displayed or sup' pressed usmg VIEw --> D t:.TA.lLS. It contains Ihe follo,,';ng \.abs: Do
Prog r am whor window Funher window~ can be di""layed within the window of the program editor: the bluck win· dow, lbo: Vcrails and Overviews window~, and the window with Ihe AS regislct!< ( f igure 2.11).
••
. . ,.. '"'' '
.--
_-
.... __.. .- ~....,.. ~
Ft~urc
The block window is automatically displayed wben openillg a block and contains me block interface at the fOp. i.e. the bluck pllrumeleno as well a~ Ihe sUllic and dynamic local dllla. You can program the bluck in the bottom program area. The block window aod the contcl\lS arc dellCribed in Chapter 3.3.2 '"Illock Window".
2.' I F..urnp]. of e
I: error ConUIlm; the errol'S foun
- .-........-. -- ._.-.~.,
,
~
2: Info Contains information on the currently .~electcd ad
SIMATl C Maoager provides an omine and an online Win dow: the one is d i.l;nguishcd from the olhel by Ihe labeling in Ihe litle bar.
~
3: Cross-references Contains the references ofaddresscs present in the current network (see Chapter 1.~6 ~Refcratce Data").
~
4: Address info Contams the symbol mfonnation of the !Oddresses present in the current network (see Chap.er 1.~.2 "Symbol Table"). You can edit e"istinl! symbols hcre. an d nC\'.· ones, and oh
In the omine window, you edit the blocks righT in Ih~ PO database. lfyou are in Ihe edilor. you can SIO .... a modified block Tn Ihe OmiDe database with FILE -+ SAVe and " 'lnsfCT it 10 !he CPL with PLC -+ lJOWNLOAD. [f you ....'alI1 10 Ia"C the opened block undeT another numbcror in R diffc .... nt project. or if you want 10 lransfcr il 10 II library or to another CPU, use the menu command flU: -> SAVE AS.
I>
5: Modify Conlains an empty table of variables in "'hich you can enterlheaddrcssc5 10 be: con1r01led (sec Chapter 2.7.3 "Moniloring and Modifying Variables'').
po
6: Diaanoslies Cnntain~" list with lite exis''''iI moni.orinil functions for process dialilnOSlics using .he S7-?O[A G option , package.
po
7: Comparison Contains the re.ults of a previously implemenn:d block comparison (sec Chapler "Comparing blocks").
You can dock or undock the Oveni"...... and Dewil... windows at Ihe edge of lite edi.or win_ dow by double cliclcing the respee.ive .itle bar. The PLC ,...giner comem... window shows the content. of the CPU rCiliSlcrs (accumulators. address regislers and Oil reaislers). IneNmeDI. ] programmln ~ Wilh inc .... mental programming. you edil the blocks both in the offiine Ind online 8/ocb COIllainer. The editor ehecks your entries in the incremental mode as $OOn as you have terminaTed a network When the block is closed iT is immediaTely compiled. so thai only error-fTce block s ca n be saved. On Ihe "Block" lab under OI'TlONS -> Cusl'OMt;,:!', you .el automatic updaling of Ih~ .... f~ erence data wben saving a block. The bl~ks can he edlled bolh offline in the programming device', dallbase and online in the CPU. generally referred 10 as lhe "programmable Conlrolle ... •. or ··PLC·. For Ibis purpose. the
With the menu conunbnd FILE -+ STUIili REA.!). Ot-.L L. in the program edilor. you can save a "T1le·protecle DOWNLOAD. If the CPU is in RUN mode . the CP U will process Ihe edited block in the nc,,1 program SCan eyc1e . If you want 10 .ave a block that you edited onlil"\C in Ihe ominc database as ",ell. you ean do so with FI1.1i ...... SAVE. \Vilh incremental prognrnmina. you cao exc~ cUle all proaramming functions wilh one c.~cepTion: i f you want 10 provide block protection (KNOW_HOW_PROTI!CT). you can only do Ihis via a program Source file (soc Chapler 24 . 1 "Slock Prolection·· ror more detailed information on this \<>pic). ChaPler 2.6.4 ··Loadinll the U!;Cr Pro~..-am into Ihe CPU·' lind Cbaptc!" 2.6.5 ~I:llock Handling'· COOIBm fuTther information on onlil"\C programmmi. Chapler 3.3 "Programming Code Blocks" and Chapler 3.4 "Programming Data 8lo<"ks" show you how 10 enlcr a LADlFBD block. D~~Qmpliation
When Ihe program edilor opens a compilod block, il carries oUl a "de~ompilalion" into the LAO'FBO .... prescntanon. It uscs Ihe program components nOt .... I""amlo c)(eculion in lhe PO dala management in order to d isplay e.3- sym~ bois. comments and jump labels.lflhe information from Ihe PG data m~nag~ment is missing
2 STEI' 7 Prot!:ramming Softw,"", durina 1M de<.-ompilation. the ednor uses replacement symbols. Nelwort<.s which cannoI be dccompiled in LAD Of' FB D are displayed in STL UpdMtlo g vr .:e n c rMllng Soure., fli es On the "Sow-ces" tab under OPTION S -+ CUSTOMt7.E. you ,,~n sek"t the option "Gener.te souree alltomatically" SO that when you save an (incrementally c reated) block, the proiJ1llrl souree file is updated or creat~d. if it does !lOt already e~i~l. You can derive the name of a IlCw source tile from the absolute address or the symbolic address. The addn!'sscs can be tnln~fCl'T'Cd in absolule or symbolic fonn to the SOW"Ce file. With the "E: .... COMrtU! in the program edilor. An STL block is created in the Blocks container. You opc'n thi~ block and switch to your usual repre~nl&lion wilh Vt\lW -+ LAD or VIEw -+ fBD. After5lv. ing. the block n!'tlIins this propeny. If you sele<:ted tbe selling "Addresses - Symbolic" when creating the 50urce file. you require a complete symbol table for compiling the sourec file. In this w~y, you can specify dif· ferent absolute addresses in the symbol table
76
and. after compilation. you end up with a proiI'lII with. for example. different inputs and outputs. This allows you 10 adapl the program 10 a diffeI'O'nt hardware configuralion. For this purpo;;e, it is best to "lore tbcse JOUI"CC files (which are independent of the hardware addressing) in II library, for example. C ompMrlng hlock s The block comparison cnables you to find the differences between twO blocks. -[be block$ c an be pr<:~cnt in different projects. in different target systems (CPUs). or in one pffljcci and One I&!¥el .ystem. Use Ihe program editor to compar<: the OJ>CIled block witb the same block in the CPU or in tile project by using OPTIONS -+ COMPAKB ON-I OFFUl'.'E 1'A1lTNER. The resolt is displayed in the detail ar<:3 of the editor window in the tab "..,: Comparison". Mark tMe Blocks object in the SIMATIC Man _ ager. or only the b locks to be compared. and selecl OPTIONS -+ COMPARF. flLOCKS , The comparison is carried out either between the online and omine data managcment (ONUNFJ omine) Or hetv,-een two proj~-.;:ts (Path I/ Path2). \Vhen comparing the complele prog",m .... hicb can also includc tables of variable!! and user dala types (UDTs) - you can inoorponlle the system data. Wh-en using "ExC'Cute oodc comparison ~, tbe prog ...m code of the bloc"," is ~ompll1ed in addition. even orblock~ wilh dif. fercm generation language!!, The ~omparison includes all dala of ~ block. \lven its time stamp for progmm code and imerface. If you wish to know whcth~r the progT'Jrn code is identical independem of the block prop· cnies, eomp ar<: lh~ ehcrksurn of the block. To do this. select the "Details" button in the re5UllS window ofthc b luck comparison.
2.5.4
Rewiring
The R""'iring function allows you to r<:1'1""" addres.
In the SL\tATIC Manag(:r, you scle<:t the objects in ",hich ynu wish lD carry OUI !he ",wmng: seleel " smgle block, a group of blocks by holdina: Ctrl and c1kldna: with the mouse, or the emire Blocks user prognn", O PTIONS -jo R..t,wuu take. you 10 II table III which you cun ~'l1 t"r the o ld addresses to ~ replaced lind tbe new addresses, When you confirm wilb "OK", Ih c SIMATTC Manager Ihen exchnn!!cS the add resses. When "re"iring" bloch, change .he numbe .. ",f the bLocks fif5t and then execute rewiring that changes lhe calb c~spondingl y. If you "rewire" I function block. its instance da\.ll block iI automatically assigned lD me rewired funclion block: the dala block number " 00. changed. Following n;wirina, an info file shows you in wbich block changes were made, and IIow many. The refer~nce dala arc no lon gcr LIp-to-date 1'01lowinl,l rewiring. and mu,l be regenerated. Please notc that "rewiring" only takes place in the compiled block.: a pWgraIn wurce. if present, is not m<.>ds ",f rewiring are: eo-
With compiled block.., Y"'u can also usc the Addren prioriry function.
I>
lflh,m: is a pmgntm source file with symbolic addre.~siog. you change the absolute addresses in the symbol mble. F"'llowing the compilation. you get aD "unwired" program.
2.~.~
Addrc~.
Priority
In the prop4T1ies wind",w ",f the ominc object CODminer Blad:.: on lh~ '"Address priority'" tab, you can .~t whcthcr lhe Ilhs<.>luI~ Itdd"'S$ or the ~y,"bol i, 10 bave pri",ricy for already saved blockJ ....ben they are displayed and saved again follo"'II1g a change I", tbe symbollable Qr 10 tbe declarati",n o r .s~;gnmCflI Qf global data block •. The def~ult i, "AbwlulC value has prionty" (the s~me behavior as in the previ"'U5 STEP 7 wMlions). This dd~ult means thm when a cban!!~ is milk in the symbol table. Ihe absolu te address i~ remined ;0 the prograll1 ulld the
s)'mOOI changes accordingly. If "Symbol bas priority" i. set. the absolute address ebanges and the symbol is retained. Example: The symbol table contains the fo1l0 .... inll:
I 1.D
'Lt mit _a~ttth_up'
I
'Limit_switCh_down"
1. 1
In the program of an already compiled bl<:x: k, input I 1.0 i, """nned: I 1 . 0 "LUnie_ _ itdo_up"
Tflhe Il!isignments fQr inputs I 1.0 and I 1.1 are !lOW changed in the symbol table to: 1 1. 0 '!..imit_a.dtch_doown" 1 1 . 1 'Ltmdt_cwitch_ up' and the already c"'mpil~d block is rtad OUl, then Ihe progmm e",ma;M
11.1 " LUni t __itc"_up'
if "S)-mbol has priori ty"' is ~et . and if" i\ Mo lute value has priority";s ~et . the proil's," contaius I 1.0
"Limit_ awitch_down"
If. as a result of a change in 'he symbol labk, then: is nQ longer any assignment t>o:twcen an ab>.<.>lute address and a symbol, Ihe 5tntemeot ... il1 c",main the absolute addrcss ,f ,. Absol ute value has pri",rity- i. set (even with symbolic display bc<:ause the symbol would, of course. be missiog); if"Symool has priority" i~ 5<:t. the Statemem i. rejected as ~'1TQT"Cd (beca use Ihe mandat<.>ry absolute address is missing). If "Symbol has pri"'rity" is set. increm~... ta lly programmed b!a<: ks with ~ymbol;~ addressing WIll retain {heir symbols in {he even! of a ~han8c to the
Pleaoe nme that this "rcwirina" does nm occur Ilutumatically bc<:all,ek - following 11K- "'\c''3.0t messagc- after it bas been opened and ~yed agaio. W order to carry outlhe change in thC complete block folder. select EOIT -jo CIIECK BLOCl( CONSISTENCY with the Blocks object mark .. d.
"
2 STEP 7 I'fn&nn\ming Sotl~
2.5.6
Reference
0.,.
As ~ supplement '0 Ihe program itself. 'he SIMATIC Manager 5hows you Ihe refcn:nee data. ,,·hieh you "lUI usc •• the hasis for 'oncelions or lests. Thew refc-rence data mdude Ihe following:
Cross referencc~ po Assignment (Tnpul. Oulput, Bit Memory. Timers, Counle~) po Program structure po Unused symbol. I> AddresSd without symbols
compiling a program source file or when 5IIving an in,rememally WTiIl\!"I1 block. Please note thaI the refcl"e11cc data are only avail able .... hen the dala are managed omine; tb
po
To generale n;f<;11;nce dam. sclect the Block< object a nd Ihc menu command OPTIONS -+ REfERDlCE DATA ~ DISPLAY. The representa· lion of the ref=~"" data can be chlllliCd .pe,itieally for each worl:: window with VlFW --> FILTER; you can save the scningo for IllIer editing by selecting WINOOW --> SA VE ARRANGIOME"". You can di.play and view several h,ti at the same time (Figure 2.12). With OPTIONS _ CUSTOMIZE ill Ihe pmj,'J1Im editor. specify on the ··Blo,,".s" tab whethc-r or nOl the referen<:e data are 10 be updaled when
C r oss r t fc ....'IIce. The cross-reference list shows the Uj.C of the ad~. and blocks in Ihe user program. II inclU
Eon _ Go To -> LOCl
The tross-reference list shows the addresses you s~le<:ted with VIEW _l'n,TER (for inSlance bit memory). STEP 7 thtu u.es the filter saved 8. "Standard" e~ny time it opens the cross.reference hSI.
---- ..
•
•• ••
• • • " •• •
2 .5 Creating ' he S7 Program
Advantage." the cross re ferences show you whether thc rcf<:renccd addre.ses were also s ~anncd or re,et. They also show you in which h locks addresses are used (possibly more than o nce). A s.]gnmen n T he I1Q/ M reference list shows which b ilS in address arC", I, Q and M arC assigned in the program . One byte, hroken down into bits. appears on e ach linc. Also shown is whether access is by byte. word. or doublcword . Th<: TI C reference list shows the timers and counter. "sed in the program . Ten timers or counters are d ispJaye<:l on a line. Advantage: the Ii" ,hows you whether certain a ddress areas were (improperly) assigned or where there aTe still addresses ava ilable. Program
. tru ct ur~
T he progr"'n stn,cnlre shows the call hierarchy of the b lo<:ks in " user program. You can determ ine Ihe >t3rt object for the cal1 hierarchy from "selection list . 'Vith VU;w ---> FIT.TfR you have a choice belWeenlWo dilt'e rent views in the prog ram structure ; The Call sfn,etur-e ,hows all nesting levels of the b lock calls. You control the display ofnes!ing le,-"I, w ith the "+.. and "- '. boxes. T he requiremenls fo, Icmpomry loca l data are shown for one block or for the emire path up 10 the assoc iated b lock. W ilh the block selected. change m ing E DIT -) 00 TO -. Loc~no:-: to the block c all, or open the b lock using EDIT -) Go TO ---> BLOCK ADDRESS. The display 'IS Dependency 5tn,erllre shows two ca ll levels. The blo<:k:; are shown (indented) in which the block po«it,on on the left is called. Advantage: Which blocks '"ere used~ \\'e re all p rogramme d blo<:ks c alled"! What are the blocks ' temporary Io<:al dma requirements? 1;; the specified local data rcquir~mcnt per priority d ass (pcr organizat ion h Inc k) .ufflcicnt? Unu. ~d S ~'mbol s
This li,t shows all addresses which have symbol table allocations but wc.,-e not used in the
prob'lam. The list shows ilic ~ymbol, th e address. the
Langua ;;: .. St'tti ng
STEP 7 otTers sev.,.-a\ mcthod, of working with dilTerentlanguages: <> The langua ge or the opC1"aling syslem (character set) <> The STEP 7 language <> The language for comments and di'play rex t
The se"ings ofrhe different languagcs are indep~ndent o f each other. l .a ngu a ge ' cl1lng s In rhc nperat in;;: .y.t em You use tile Windows ~ontrol pane l to se lect thc characler set with wh ich you want to w ork under \"indow,. You can find thc ehamct"r selS le'ted with the mult i- language ve rsion ( M UI "ersion) and the restriction. wbcn operatin g with S TF I' 7 in the currt:nt Readme tile or in ilie STEP 7 11elp under ··Seni"g up ami cditing th e project"". Proj~ct
lan gua;;:e
The project language is the lan g ll3ge that is set in the W indows eontro l panel w he n the projecl is created. T he SIMATIC Manag er ind icates the language in which the selected project or the sclected Iibrllry has been erealcd in E D IT ---> O n JECT PROpeRTIES. "Not yer de tl ned" means you can me the project or the library lan guage- neu trally, e .g. in multiproj e~ts. These are alw ay s language-neutral. In language- neutral proj eclS or libraries . only characters of the ASCIJ chara cter set can ~ used (2Ahc, to 7F hox )' You can
2 S'I'EP 7 Programming Software
find additional informalion in th~ STEP 7 Kelp lIn der "Settin g LIp and editing the project". STf~P
7 langu 3\:c
Thc S<.'Ssion language of tht: SlMATlC M"nag~r that \kfines. for e~,~np l c, til, m~IllJ "ames "",I the error mes""gc,;, is called the STEP 7 language. Y01..l ""t this language in the SIJ\1ATIC Man;'g~' on the "Langu ag~" !:ob with OI'TIO~S ...,. C usTOMJ/.I-~ 'The languages installed w ith STEP 7 are offered for ",Ie",tion llndt.-r "Nationall"nguag<:" . On this mb you also set the programming Illllemoolcs, that is, the language in whi~h ST£I' 7 uses th~ op<.="d, and operation<. e.g,"to. I" (II!'.'£) input for Engliili), or " U E"' (for German). j\-'I ultllingual Commcnn a nd Di.play Texn Comments and display texts can be multilingual. You hav~ entered the lext> in tbe original laJlb",age, rueh as English, and you "'an ( (0 generate a German ve"ion of your program. To do so , ~xpon tb~ desired texts or text type,. Thc e~p
mation on the e~ported types of t""t, and any ~rrors whkh ba ve occufT~d , Open the export tjle(.) w ith th e FILE ...,. OPFN dialog box in Mi~mwfl Ex cel (not by doo.h\eclicking) , The e~p
Sdecling and ddel;Jlg a language
Wilh OPTtONS ----> LAl':GUAGE FOR DISPLAY DJ::_ VTr:E~ in the SThtAI1C Manager, you ,elect the languagc" available i~ your projc~1.. and Y"'" ""t the standard language tor the di.play tenn inal, .
You Can change to all ; mj)Ort~d languages in lhe SIMAnC Manager w ith OPTlOKS ----> MANAC[ MULTlLlNCUAL TVx rs ...,. CHA~'G£ LANGUAGI': . The language ohange is ~xeeuted for the objec," (blocks, ,ymbol tab le) tor which the relevant text< have b.-en imported . Thi. information i, contained in the log file , Y"u Can make funher .etlings. e.g. tbe --taking over" of multi lin gua l comments when copying a b lock, Il.,ing OV t'IONS ...,. MAI"AGE MULTiLINGUAL TExTS"'" SJOTTINGS I'OR CO),L"-ti:Nl M"NAGJ:"""'T. You can delete the illlp -"1ANAGl' MLIl.m.lNGUAl TEXIS --,> DELETE LANGUAGI'.
Exporting mId impmti,,!; /exls
'fable 2.2
Select the obj c~t in the STMATIC Managercon· mining the comment. you wamto translate, c .g. the symbol wblc, the blvd; ~ontainer, . e ,·eml blocb or a 8ing1c block. S~IC<:t OPTIONS ----> MANAGE M{;LTllt~GU AL TEXTS ----> EXPORT. In the dialog window ,hI (hcn appears, emer th~ storage location oflhe ~xport fik and thc "'rg~t bngunge, Sclect the text types that you want to translate (Table 2 ,2) , A separa te file is generated for every t..xt type, e.g. th~ fiJc SymbolCommcnl.CSv for the com ment. from the symbol table. E~i"t in g e~port tiles can be expand~(L A log file provide s infor-
Tnt type, uf tho rran,1ated tens (se lection)
titl
itt
2.6 Online Mode
2.6
O nline Mnde
You creme the hardware confill"notion and the "ser prugr6m Olllhe proarammina device. generally IVf"."..,d to as the ··engineering system·· (ES). ·rhe S7 program is stored offiine on the hard disk here. also in compiled fOOTI. To transfer the progrdUl to the CPU. yo" must connect tbe prognunminll devicc '0 thc CPU. You establish an ··onlinc·' connection. You cM uSe this eotUlection to det~nnjnc the operaling ItHtC of tbe CPU and the ~ssiiln\X1 modules . t.e., you can CHrty out diagnostics func!iolts .
2.6.1
C onn.,.,tinga FI.C
Thc eQnf>C"Ction between the progmmmiog doviee·, MPI in!~.,.faee Il!Id Ihc CPU's MPI interface is the mechanical requtrement for an online connection. The conncc1ion is unique when B CPU is the only progu.mmahle module c()l!n«t~d. !ftllere arc severa! CPUs in th~ M1'l subncl. each CPU mu,t be assigoed a unique nadc Ilumber (\1PI addreSll). You set the -"11'1 addlV~ when you initiHlizc Ihe CPU. Rcfore linkmg all the CPUs to One netwon:. connect the pru$1"&mming device 10 only one CPU 8 time .nd trnnsfer the Syslem f)Qlo object from Ihe oftline US<."T pmgram Blacks Or direct with Ihe Hardware Configuration e;litor using the menu command PLC -+ IX)w.'LOAl> . Thi. "ssigns a CP U its own special MP I addres s ("·uaming··) along with the other prop~rties.
The MI'l address of a C PU in tl:e MPI network can be chMged at any lime by mmsferri;g a new paramet~ dala record conlllit"l1nl! the no'w MPI add",,,,, to the C PU. Note carefully: the new MPI ~ddres s takes effect immediately. While the progranuning device adju.l. immediately tothe new address. you mu." adapt other arrliea(hm~. such as global d~ta communicalions. to the !!ew MPI addrc5S . The MI'I parameters are retained in Ihe CPU eVen .ncr a memory rescl. The CPU can thus be 1OddreS5ed evcn al\cr a memory reset. A programming devicc Can alway~ be opernted o nline on a CPU. even with a module-indcpcn"'~nt program and even thoullh nu project has been Set up.
If "" prQj~ct has be~n . et up , you establish Ihe
~onneclion to the CPU with PLC -+ DISPLAY AC'C[SSJDLE NODES. This seree!!s a project
window with the structure ··Ac{)t!fslble Node.. ·· _ ··\.ladule (MPI=nf" _ ··Online User Program (Sloehr. When you sde<:t the /If,xl"le objecl. you may utili,..c the online functions, ~uc b "" dunging the optr,uional ~Iarus and checking the m<, the online system data are louded O!\lO the hard disk. lflhere i~ II CP1:_i nd~prnd~nl pTOKram in the project window. create lhe as.tociated online project window. l!several CI'lJI arc connected to the MPI ""d actessible, .' el""'t EDIT -+ OElJFCT PRoPJ:RTlES with the online S7 pr0gram IICleeted and ""t the number of the mountinll rack and the CPU's slol on the "Addre,"n Module·· mb. If you scle<;t the S7 Program in the online win· dow .. U the online functions 1<> the cotmect<.-d CPU..,... ""allable lO you. Bloefu show. the bloch located in the CPU's u5Cfmemory_ lfthe blocks in the offiine pro8fllm agn.;c with lh" blocks in the online program you can edit the blocu in the user memury with 100 infonnation from the data manag~ment ~y5tem of the pro. i1rnmming devic e (symb<:>lie address, com· menrs). \Vh",n you switch II CI'U-.SJjKn~d p rogram inlo online mode using VIEw -+ OSLlNl:, you Clm carry OuL program modifielllions just as you would in a CPU-independent program. In addilion. it it now "",""ible for you to e
2.6.2
I'rottctl 0l:
th~ (;.~r
P rogra m
Wilt. aPl'ropriatc/y equipped CPUs. access to the U1t\:r progrnm ean he protected with II pllh' word. Evcry<>nc in pooSCl'sion of the password has unresUicted access to the userpl'tec t;on level' with the "ProteClioo" l" b of the Hllrdwur~ COllfigllmti(}ll tool when pannnctCT_ ,,,,;nll: Ihe C PU, The acc eS!l ~r ivilege using the ~"".word applln "",,llhe S IMAT IC Manager has hem exite" or the password p'<>''''''ion cancdod again us,nj Pl e -+ At"('·fS!> IlI{;HTS -+ CA."ICEL. "rot~lion
le,'e l , : mode sd.,.,ror s .. itch
TIli' protection level i~ sel HI def~u!! (WJ!l::out "".sword). With CPt). with a keylock ~wil~h, prol~tion level 1 i. used tn set protection of th. usc, l"'lIlTK'" by the mode selector switch on die fro tH of the CPU. Tn the }{UK·P and STOP "",itions, you have unrestrictcd acceSS to the uSCT program; in th e RUN position , only n:!ld lIecen via th~ programming device is possible. IJllhis po:lilion, you can also rernO\-c the keylock 6witell,." , h.at the mode c..., nO longer be ctlangl.'d via the ~wi'eb.
You can bypass prmection via the I:eylock switch RUN ~irion by selecting the OptiOn ··Iot cmovallic with Jl'I.~swonr. e.g. if the Cl'U, and with il the I:eylocl: switch, are nO! easIly """,",nible Of "'" located lit a di.tanee. lflhe mode ~el ee'or ,wi,eh is d.:.igned as B toggl e sw ilCll, protection level 1 m ean5 &0 limiTati on in aetCi«! to the user pn>gram. With th~ system function SFC 109 PROTECT, Ihe wri te prol~""lion (pn,tcetion level 2) Cion be switched on pnd off via the pmgr~m in protection level I (Sfi: Chapter 20.3 .8 "Chan;:in¥ propm protl,dion'"). ProTection Icvd 2:
1\";t~ prol~tlloD
At thi~ prutection level, the user proiO'IT! ~·1ltI o nly he read, reganlle« of Ihe position of the kcy lo>ek swilch.
f'1"tK~ elion
lenl 3: rfl"3dl .. rite protec tion
1\"0 access to the """program, regardl""", orthe keylocl: .witch posi lion. Exception' reading <>f diagnostics bttifer and moniloring of va nab Ie. in tabl ... i.< pos>ible in every prolection level. I'a~'word
p r ntettiun
If you ,elect protection [cH I 2 or 3 or protec_ t ion 1.".·c1 2 with "RemovlIble with pas~w"rd", you will be prompted to defmc ~ pa ssword. The l"'s~word can be up 10 II characIC1"$ 10011". Tfyou try to access a u><:t: program thai is prot«led "~th a pas'
'Ulled.
Every'm<: in posses"on of Ihe password has lInreltricted 3ecc~s 10 the U$C1" proP"' in the CPl; "'!I...-dJes. of the protection le\"el ~ and ~gardlt'Ss of Ihe keylock pOlo;"""' 2.6 ..1
C P U inform a l ;"n
In online tnO<£, Ihe CPU infomuuion listed below is availabl e to you. The menu command.. ~ re screened when you have ""I~...,t~"" a modu le (in on line mode and without a project) {" $7 prollrum (;n the online project window). ~
Gene<1l1 information (such as ~rsion), diag_ no"ic~ huffer, memory (CU"""I map of work mC"lllOry and load m emory, ""m pres~ion), cycle time (length of lhe last, longut, Bod shonesl program cycle). timing ,y~lem IJ)<0pi!rtie s of the CPU clock. dock syn _ chronization, run-time mctcr), perfOnrulllCe
2.6 Onl ine Mode dala (available organi:~.n ion bJ(X;kli aDd sy.Icm blocks. sizes orlb" address arcu), communicat ivn (data lransfer rnt~ nnd CO mmnnical10n links). ,lack, in STOr stat ~ (B stack. I Slack, and L sTack)
-+ OrEIl.ATI:'G MODE of the eUlTl:D1 operallng mode (foc instance RUt>. o C STOP). mooific;aTion of the oP='ting mode [), ~play
-+ CLf.ARlRES ET Rcs.clting oflhe CPU in STOP mode
-+
S ~r
Tn'lE Of DAY
Setting of the internal CPU doc k and . 1n Ihe enhanced dialolt - me diffetcnce from a lime ZOne ~
:>
PLC -+ CPU MF_'i.~AC.F_~ Rrporllng of asynchronous system crTOT!i and or user-defined mCSSl.lgel GenCf9ted in the program will SFC '2 WR t.:S/I.·tSG, SFC 18 AJ.ARM s. src 17 ALAFU.I_SQ, SFC 108 ALARM D and SFC 107 ALARM DQ. PLC -+ iJlSI'l.AY FOR.CF VAL1ffi~, PLC MO:-fTOR./Momry VAR.IABlES
-+
(see Chaplers 2.7.3 "Monitoring aDd ~odi fyinK Variable." and 2.7.4 ~Fordna Vari_ a ble$")
2.6.4
Lnadlng Ihe (JStr Pro!:rilm Into the C P U
In the CIS(: ofa RAM load memory (integnlcd in the CPU, a. a memory card o r micro mcmo'Y card). you transfer a compl et e user program by "WilChlllltl: thc CPU to Ihe STOI' Slate, performing memory ..."ct and trnnsferrin\!lhe user prognorn. Tbe configuration dala are aJ.o U-dUBferred. If you only WaDI to cbange the eonfigur.llion dalill (CPU propc!1ies, the cOllfigured connlX'tion~, GD cOnuDunicaTions, module parameTers. and 50 on). you n~ed only load Ihc System Data obi ""t into the CPU (sclect thC objeCT and transfer it with menu command I'LC -+ DOWl>!I.OAV). The parameters for tho CPU go imo cireci immediately; The CPU lransfers Ihe parllmCTcrs for the remaining ,nodule. 10 those modules during "tartup. Plo:asc nOle thaT The enlire: L"Onfigurdtion i. loaded ooto the PLC witll the Sys/I'''' data object . If )'ou I.\l'O: PLC -+ DOWN r.oAD in an application. e.g. in global daTU communications. only (hc data ediTed Ily the Hpp l icaTion an: transfcm:d. NOIe: ~r:lect PLC --;. SAvt: TO MIS..I,tQRY CAKl) to 10Hd lhe compressed arohive Ii Ir: (s.ee Chapt.c1 2.2.2 "Managing, R.eorxanizi nll and AIl::lliving-). The project in Tbe archive file cannot be ediled direct either "ith the programming d evice or "om thr: CPU. 2. 6 .~
Bl ock Han dlin jt
When you U"lIn,fer your user progrnm (compiled blocks IUld configuralion dUla) to the CPU. il is loaded into the CPU'S load 111<':1110ry. r hy"i<,:alLy, load memory Can be I memory inTeinlled in the CPU. a memory card. or a micro memory card (set' Cbapler 1.1.6 "CPU M ~mo'Y
1"rllMfcrrhl K bl".,k.
Area~· ·).
You transfer individual blocks to the CPU b y selectin\! them in the omine window and selecting PLC -+ Do"'NJ.OA" With Ihc offline and online windows C>pCned al the ~ame lime. you can also drag the block! wilh Ihe mouse from one window and drop them in tile otb~"1".
Wilh a micro memory card or 8 flaSh EPROM mcmo'Y cord you can wrile die card ill th .. programm in g device and usc il as d3ta m~dium . You plug the can! into the CPI) in the off-circuit STale: 00 power up follow ina memory re'<'I. the rcle\"8n l dala of the card a~ transferred to the work mcn>O'Y of{b~ CPt.:. With Ipproprialely equ,pped CPUs. you can also OVCTWnle a fln.>h EPRO\1 memory carn or a miero memory card if il il plugged inlo!.he C PU. but only wiTh The entire program.
In the eil."" of a R.AJ>.t IODd memory. yol.\ can HI$O modIfY. delete o r reload indi vidual bLocks in adduio" to =ferring Ihe entire program online.
Special ~an:: is needed whcn transferring ind i· vidulll bloch during opr:ralion. I f blocks thai Bre: OOt avaiLable in Thr: C PU memory arc called w;lhin a block.. you mUSI firsl load the "I",,'crle,"er' blocu. This also applies ror data bl(X;ks whose au dr\;sscs Hrc used in the loaded block".
2 STEP 1 Prujlrlln,m;ng Suftwate: You load Ihe ··highesl· le,·er· block last. Then. prov;d~-d it is ",,1100. it will be ex ecuted immediately in Ihe ne"{ program cyele. Modlfyln!,:: or delellng blocks online Ynu can edit bloch incrementally wilh STL in the online u~er program (on the CPU) in ~xa cI Jy the 8ante way as in the offline mer proW.. ,n. With a pro:,:rammint: dc,·icc connected online to the CPU. you can read. modify or d~lele blocks in Ihe load memory. If the RAM eompOnem of the load memory i~ !Drge enough 10 accommodate the modiliod blod.s. Dwino; rumime, the modified blocks in the RAM nrc ~a]jd. Ih ose in the FEPROM IS invalid. rlea.e nOlO Ihat you must I""d Ihe original blook.s again from the FEPROM into Ihe work mcmory following an overa!1 reset 0.'''.on-burrered ~wilchin8 on. If you U'"' II micro memory card such ... C.Il. wi lh the compact CPUs. all bl""ks in the load memory are oon_volatile. You can modify indiv idwd blocle.lell<.'y (c.t:. a ··time ,tamp conflict·· when the i"teTraee of the called block is later than the program in the calling block).
The following ,till applies CVo:tl if you "or:k online: with FlLE ---+ SAVE you $ave the eUf'"l"Cnt block in the offline uscrprogrnm in the PO data manaw:ement; with PLC _ DOW/,>WAV yOlJ v,..rite the block back into the user memory ROO the CPU. Comp .... soing W~om
you load a new or modified block into the CPU. the cru plac~ the block in load memory and IransfcnI the relevanl data to worl< memory. If tbere is already a block with the same number, this "old b lock" is dedared invalid (following a prompt for confirmation) and the new block "added on at the end·' in memory. Even a deleted block i8 ··only" declared invalid. not actually ~mo"ed from memoryThis result, in &Ilf>" in user mcmO!")' whi ch increasinw:ly r.-duee the amount of memory still availahle. Th~se gap' Can be filled on ly by the CompreH function. When you eompre$s in RUN mode. the blo<;b currently heini c"ecUled are not relocated; only in STOP mode can you truly achk~c compres.'ion withoul g"p". The eurrctJt memory allocation ~an be di s_ plnyed in percenl with the menu eommand PLC _
DIAG:
\.tATIO". On the ·-Memory·· \.lib. The dialog 00" "",eh then appean also ha.ii a bunon for pre\"enti~·e eompressiOD.
You can initiate ",-'ent_driven compre~ing p<.'r pmgram wilh th~ c a ll SFC 25 COMl'RESS. 0018
b locks olTIineiulIllnc
I)urino:: programming. you ~~sign tile dam addrc,"cs in a data b lock wilh I' default value and an initial ~alue (see a lso Chapter 3.4 .. f'ro.grnmming Data Blocks·'). If a datM block is loaded into the CPU. the imtial valUe!! ftre traM_ r=cd to load memory and subsequentlY to work memory, ... here they become ....'ua1 values. Every value change made to a
2.6 Online Mode
If a spoci.1 .",n ".lue .. "'" p"'f-rammod. !he del...... " is usN
""we
IMiaI value When dnwnk"dWjj; '"
lh~
rpu.
lhe .an v.luo f\, ' ","" f< "",~ from !he .>11]'''0 data manall"mrnl ... 1<>&4
~"'...,. Tho >tart , . ,,,,, '" the ~ m<:m<><)' i, 1101' inn' .... <'Od by !l»r..
Initial vaIu ..
~[t..;.. .... ,
:"~2l"~~..:'~~ ... ilEAl) DRr _ WRIT .DDL i1
(
~
Adua/ ~ a lu"
in the
pro~m editor 10 the oftline data management using FILE ---} SAVE. TIK: nameS of lhe vari~bles and !.he data tyPCs sa~ed in the offline dala manaijcment are 'hen rers ined. If yo" upload Ibe onl ine dma b lock in the SIMATI C Manager n.ing I' LC ---} UPI .OAD TO PO or by dragging Ihe d~la block from Ihe online win. dow to the omine ""i ndow in the offline dalD onanagemem. 'he descriptiotl of Ihc addresoes. such as c.g. the Mme of the variables or the dala Iypc, i. 1000t .
lfyou upload a data block from the CPU back iOI<> the omine data management . the actual ~alucs pre".;nl in the work me mory are imported mta tbe omine data management as inil ial ~a lues . This does not change Ihe initial values in the load m~mory. Following an ovcra ll r~sel or nUD-buff,,-rcd switching on, and " ' hen nsinll a nuh EP ROM memory card or a m icro memory card, the (old) initial valu~s PTCScnl in the load memory are import~..J ;",0 Ihe work mCDlOry as (new) actual valuc~.
I
SIT 5<
..
'1"110: O\UI , ~tu. bt<;"",,,. • 'he ""uol ,' atll~ in rho: work mo"w'~. The actual ,.~"" ;"11>< ""I ... madiO..l by
If you wish to import the Bernal ~"lue.~ into the load memory when nsmg a RAM load memOf'Y or a mi~'TO rmmory eard. l<>ad lhe data b lock from the CPU into the prolll1'mminll d cvice alld then haek again into thc CPU. CPUs wilh mi~ro mem ory <.:fiTd provi de the syst~'1n functiun ~FC 84 WRIT_ DilL with which you clln directly write actual w lues in\{) the load memory. Wilh correspondingly d~;gned c ruS, you can InInsfer the complele eonlems <>f t~ work memory into the ROM comp<:>nenl of Ihe load memory using PLC ~ COpy RAM TO ROM. A wna b lock gel]enltcd with tbe property
Unlinked is Dot IJaIIllfcrTed 10 "..or!< memory; il remains in load memory. A data hlock wit h Ih is property can only be read with SFC 20 BL KMaYor - with corrCSp<)nd in8l y des igned CPUs-with SFC 83 READ_OB L. III incrementa] programming mode, you ean create dala block'l direClly;n the work ~mory of the CPU. It is recommerldable to a lso ..,ve
2 STEP 7 Programm inl! S()i'tv"are
Ihe.e blocks been ~rcalcd.
oftlin~
immediately Ihey have
With the system f\ln~li()ns SFC 22 CR.£AT_ DB. SI'C 85 CREA DB and SFC 82 CRT'A_ DB L you can genemtc dara b locks during runtime where Ihe d escriplion of lhe addre",~ s, 5uch a.s the "am~ of the v ariah le and Ihe type of da la, arc missing. When re ading with the pm_ gramming device , a I:IYTE field with" name and in dex assigned by the program editor is th ercfore d i,playe d.Ifyou tr~nsfer such a dam block to Ihe om ine data management, this duelaral io n is imponcd . If the data b lock has Ihe property Un/inked, th ~ ini ti~l valu~8 from Ihe lo~d memo ry are imponed into th~ oftline data manag~ment as neW ,m lial valu~s . otherwis e th~ aelual "alllC' from the work m <:ruory. Wh~"I1 tran sferring to the offiine daw managemenL Ih e e hed,,;um of thc (offiine) pmgram is ch anged ,
2_7
Testing th e P rogram
After e "lablishing a conneclion t() a CI'U and loading the user progr"m, you can lest (debug) the program as a whole or in pan, such as ind ividu al b loch _ You initialize the varia bles w ith
thc h elp of Ihe function "'Diagnose Hardware ". Yon co nnec t the pml.""mming device t() th~ MPI bu s and stan the SIMATlC :\1anagcr. !fthc project as socia led w ith the plan! configu_ ra tion i s a vailable in the progra.tmniT1S device databa_,e. open th c online project w in dow with V IEW ..... O'NLrnT•. Olh~rwisc , ,e lect P LC ---> D ISPL .... y A CCfSSlllLE NODES in the SLvlAT IC M a nager, and s ~k~\ the CPU . Now you can gel a q ui~k overview of the fauity modu les w ith PLC --> DIAGNOST Ic/SETTI NG ..... HAlW WARE DIAGNOSTICS (default In the SIMATIC Manager lInrl .,,- O J'nONS ----> ClJsTO)'flZE in Ih~ tab "Vie,,~'). If the quick overview i. dc.elcc led, you are provided with the detailed d iagnostics in fonnation of all nl{>d"I~s , l fyuu ar~ in the lIard"'arc Configu ration tool , 8e1ect Ihe onl i n ~ vicw u,ing VlLW -lo ON LL, E, You ~'lll now d isplay the existing di agno"ties information for the sele cted module ""ing PLC -lo MODIiLr. Jl','FOR.'I,fATlO,,·.
2. 7_2
D ctcnninlnR t h e Ca u se of a STOP
If the CPU gCK""S 10 STO P because of an CfTor, th e liThI m ~a.sure to tak e in order In d etermine the re~son for the STOP is to ou tput the d iag nosti~s buffer. TIle CPU enters all m essages in Ihe di agnostic buITer, including the rea s on for a STO P and the e rrol";<; w hich led to iI, To OUlpUl the d iagnostic buffer, switch th e PO to onlin ~, select an S7 program, and choo8e the "D ia gnostics BulT~r'- tab with the menu commami PLC --> D IAGNOSnc/S FTTDIG ..... MODULE INFORMATION. The last event (Ihe one with the number I) is the Cause of the STOP. for instanc e '"STOP because programming efror OB not lo ad~d - · . n , e error which led to the STOP is described in the pre ce d ing me"~ge , for c .... amplc "FC not Inaded" , By ~licki " g on the me~sagc n umber, you can screen an add it iona l com m e n! in Ihe ne.~ t lower display field . lftbe message re lates to a programming error in a block, yo" Can opcn and edit that b lock with th e "Open Bl ock" button. STOP is. for exa m ple. ~ p rogramming eITor. you Can asecna in the surround ing ,: ,n:umst ance s with the " Stacks" lab_ \\'hen yo u open "Slach"". you will ,ee the B sl a~ k ( b lock stack) , w hiCh s hows you Ihe call
If the cause
2. 7.1
D iagn os ing
t h~
H a rdwa "e
In the event of a r""It , yo" ean fetch the diagnostics informalinn nf th c fanlty modu les with
ofth~
2.7 TOI-tinathePrognm path ()f ..U n()n_t~nnillated blocks up to the block contain in g t~e interrupt point. U.e th,, ·'] ~ I ack·' button to 8creClI the interrupt stack, which ~how. you the COntentS of the CPU regist~T!l (accumulators. address r.:ais:er. data block "'ii'ler, stalUs word) at thc in«'"Tnlpt point at the inst.ant the error occurred. Tbc L s\.IIck (local data stack) shows block's temporary local data. which YOII sclC<.'t in the 11 slack by clic king with the molls.:.
me
Plellse note tha\ YOll can only modify d.!ta "ddre•• es iI tbe wrile protection for the data hlock i~ switched off, i. e. the block l' rop"ny Dfl Is ""t"II~_"ml~ckd in Ihe AS ill n01 nClivatcJ. Opcl"\I.nds in data hlod..:s with Ihe block propert y Unlmked cannot be monitored since the." data blocks are located in the load memory on the micro memory card. A one-off updale takes plan who:n lh" data block is opcIled online.
Caution. Y"u mus' s'al~.1
2.7.3
,\lonllorinl: and
/ll o d lf~· ln l:
VarIab le.
One exceUc[}\ resource fordebugging user prc>i, the monitoring and modif)"ing ofvari_ Bble~ with VAT ~"ariable table". Sigm" Slates or values of "ariabl~ of dementllI)" data types can be displayed. !fyou have aeees. to the uscrprc>pm. you can also modify variables, i.c. cllilnge the .igllal state or usign new values .
gr.tm~
FI Ku r" l.U Variable Tahl. Eumpl"
etW'", '/lUi no dongerou.. Can ",sullfrom mmlifj·j/lk mrl"b/e.. !
Cru tltl]:t a va rl a hle rabk For monitoriog and modifyinll variable.., you mu~t C~a!e a VAT variable table containing the unables and the as.
You can g~ncnll" a VAT oftline by $"le~linl:: Ihe p"'lP""m Hh..ks ...,<1 Ihen l.>'SCRT ..... S7 BLOCK ..... VI\IUNlU! TtillLL. and you cltn ,en~-r~IC Iln unn..mcd VAT online by selecl ing S' Program and 5<'1ec1illg PLC ..... MO~tTOpJ M oolI'Y VI\!UI\IlLeS. US/,,-r
YO LI Can ~ t">ee i fy the va riahl"" with e ith er nbsoIm e or symbolic addresse s and cl,,><>se tbe dUTU type (di~play lonnal) wilh which a varigbl~ is 10 be disp lltyed and mod ifi ed (wilh ViI::" ..... Sr:L[CT DlSnAY FORMAT or by clicking the ri,hl muu~ bUlion dircclly on the ··Disp lay fl'rmat"). Usc COmnlenl lines 10 b";\,C specIfic sce,ion~ l'f the table _ header. You may also stipula'e which columns are to be displayed.. You can c hange variable ordi~pby rommt or add or ddele line~ al any tilllC. You ~\'e Ihe variable table in Ihe HIOl"b object con"'iner wilh TAB!..!; ..... SI\V£. E~tllbU5 hl nlt
a u oulin e eon n ectiun
To operate a va ri able table th'" has been ~rcatcd otUine, switch ilouliue wilh PLC...., CONl."NF.CI.
\ Ion;turi nx ,·a rt. h le... SelC<."t fhe :\·Ionilor funetioD wilh Ihe menu con,mand V-'lUAlIUl ..... M OKITOI(. The vari_ abl .... in the VAT"", updated in accordancc wilb the specified triS8C1" condition.. Pcnnanenl mor.ilofill g a llows you to follow change .• in Ihe values on the """,cn. The v ..1ue. lire disp layed in Ihe daTa fon n at which YOLl .et in the '·D i'play formal" column. The ESC key temlinales n p~r ",~nent mo.::lllor fWlctinn. VAlUABLE ... ACTIV ... re M OD tr:v Vi\LU':S the monitor values on",c only and immediutely w;lhout regard '0 'he specified trigger ~"OIldition8. update~
) Iod if)ina; ,· .. rlab l... Use VAIUABL(' ''' MODifY \0 ,ransfcrthc ~pcc ir.~·d "aluc~ 10 the CPU ,kpendent on the trigg~r conditions . Enl~"T v alues only in Ihe Ih,e. eonI" inin, the variab les you want In ,,.,od if'y. You can c ~pand th e commentary for a ,-a1u, .... ith ·'Ir· or w id , V>UUAlII.Il ..... MOllifY VAI.UIO AS COM-'lL"'; th~,c values arc nOl laiL"TI iuto accounl for modificat ion. YOII must define Ihe \"alu~s in the da la fOlTlllll which you sci in ,he ··Display rurmat" column. Only Ihe value5 visible on 'taning ,ilc modifY fU'lOtion BTl: modified. The t:SC key t~rrninate~ a permanent mod_ If)' function.
,l:.
In Ihe variable table .•elect V... IUAlILE ..... TlI.Klou to " tthe Trigg:~r point and the tri;:;:cr CODd1tiQn~ $Cpamlciy for mon itoring and modify_ in g. The trigger point is the poiot "t which the CP U rends vu lLles from th e system memory or wri lC$ values II) Inc system memory. You 'P""'if)' w h ethcr read ing and writing is to lake plnce ODCC or pt:riodically.
Wilh appropriately e
If monitoring and modifying hav~ tbe 5IIme triggcr Condit;01l~, monitoring is carried OUI bc r(l1"C modifying. If you selecl the uigser f"l'Omt "Sta" o f cycle'· for modifYing, Ihe variables are modified afl~r updaling of the procCi. inPUt image itOO heron: eallin!,:: O F! I. If you selccII"e trigger point "End of cycle·· for In<>D..itoring. the ~lal US vMill"" MTC displayed after lerminalion of 013 I a nd before OUlPUI of 'he proces~ OUtllUI
The starting point fur forcing i< a "ariJ.bJc table (VAT). Create II VAT, cDtcr the addfa
Lm:,;:c .
FOR.ce V ... L1WS.
.
Call1ton: yt1U must eTUurt! Ihul no dang~'TOu" ..fOft:.S can result from fOlrmg l"Oriuhl.,.,,!
2.7 Tesrillll the Pl'Oj:Jtw If there are aLre-.ody force "alu~s active in the CPU. these "'"" indkated in the force window in bold type. You can nOw transfer some or aU ad dTC5!
Inputll (preens image) [S7-300 ami S7-4001
t>
OutputS Q (proces5 image) [S7·300 nnd S7-400]
t>
,''''';phernl inputs PI [57-400]
t>
Peripheral outputs PQ [S7-400)
:>
Memory hi t ~ M )S7-400]
You stan Ihe for~c job with VARlABU! -+ FOR.CIi. The CPU accepts the force valL.lC' and p"'mut~ no mo,e changes to the lorc<:d
addrcs!
Fcm:ioll is also deleled by memory n:$et Or by a P""'CT failure if the CPU is not battery-backed. When forcing is tenninated. the lIdd rdlsc. retllin the forcc vlIlues until o,"crwritten by ~itbcr the user program Of the ~y~tem program . Forcing;' dYcdivc only on 110 lIssigncd to a CPU. If. following TCstan. forced peri ph... ral inp"ts and outputs a re no longer "SlJ igned (c.g. a~ a resu lt of r~pa mmetcri:Ging). eh ... relevant peripheral inputs and outputs an.: no lODger for.::ed. E rro r h andling Tfth... aeCCS5 width when reading is greae~"T than Ille force width (c.g. forced byte in a wOt"d), the unforced component of the address value ill read as usual. If a synchroni~al1oo error ""'CUIS here (pc,",c"" <.>T arca lcogth CITOJ") tt.c "'error substitllle valuc" specified by th~ user progr..m o r by th~ CPU is read or the CPU goe!l CO STOP. rf, when writing. the access wideh is gre"tcr Ihan Ihe force width (c.g . forced byte in a word). the =forced comp'".,e,,! of tlte udd rcss vuhl~ is "'ritten to as u
All read acce.~ to a forced addre,,~ via the user T'rogram (e.g. load) and via the systcm T'rogrwn ("·11. vpdatmg of the prace". image) always yield the force value.
Loading forced pcripheml inpul.>l yields 11K force value. Ifthe acc::ess width D(:TC-e!I w ith ehe forc::e width. input mooulcs that have fniled u r hD'·... not (yet) been plugged in can be ""rqllll(;ed" by .. fOTCe value.
'" On tIrcS7-400, alJ ...rit"It(X'"";;~ 10 II ~ IKIdres5 viu the US~"T progmm (c.g . Iransfer) a nd via thc syst~'" program (c.g. via SrCI) re ,uain w ithout effec t O n the S7·300. the uscr program Cnn ovelWrite the force val_ UC$.
T hc inpor I in Dcd and can sti ll he overwTitl~n. \Vhen updating lhe process 'mnge. the i'l["Iul receives !.hc for.::~ value of the peripheral innut.
t>
Forcing on eh~ S7-300 corresponds co cydic modifying: aftcr the process input image ha~ been updated, th ... CPU o,..,rwrites the inpuUl with the force value: before the pr<>ees, outpul image is OUtput, th~ C P U oWf'nites the oucputs wieh ehe force valuc. NUl,,: lorclng is '101 lerminaled by du.,inK III... lorce w;nuowor Ihl! , ... rlab/e /able. or by b1V'Qkinc tit", ccmn«rfcm 10 tit.. CPU! Yo" "m, only ddele olorr:ejvb w;th VA'ITARtE -+ STOP FOJi;C",,0.
"so-
When forcing peripheral outputs PQ. the c;"ted Output Q in the pf""'CS~ imag~ is not updaled and n
89
2 STEP 7 Programming: Sofuvare
output module, at STOP, HOLD o r REST>\RT) - even if the peripheral outputs are forced (excc~ption: analog module, wilham 00 evalu_ ation continuc [0 output [he forcc value). If the 00 5ignal i. deactivated, thc force va lue becomes effective again.
If, in STOP mod~, the function En"blc PQ is activated, the force value s a l,o become effective in STOP mode (due 10 deactivation of the 00 signal). When Enable PQ is term inatcd, [hc modules are set back to the "safe" state (_;gnal ,tat~ "0" or ~ub.ti lutc v alue): th e force valuc becomes eff""tiv~ again at the transition to
RUN. 2.7.5
Enabling Peripheral Output.,
Itl STOP mode, the oUlpm modllks are normally disabled by the 00 s ignal; Wi lh th e Enable peripheral oUlputs [unct ion . you can d~act;vate the on signal 00 lhat you can modify the outpm module. ev." at CPU STOP. Modi_ fying i. earried am via a variable mhle. Only the peripheral ompms ass ign ed to a CPU are modified. Pos,ihle apr>lic3Iion : wiring test of the oUlr>m lit STOP and without US~r program.
Camion: you mil'" e'".,m' that no daflRcmu.< stales am re~u/l jr"m e""bling the paiphera/ oulp",,·.' Create a variable table and enter th~ peripheral outpul<, (l'Q) ami the modify value, . Swi tch thc variable table online with PLC -.> CONl-.'ECT 10 -.> ... and stop Ihe CPU ifne~essary, e.g . with PLC -.> OPEItATlNG MO DE and "STOP"
tion to REST ART and deactivated again at the transition to RUN.
2 .7.6
Test and process operation
The rceording Df the program ,tarns infmmation re quircs additional cxecmion time in the proo:r.un cycle. For this reason, you can choose two opcrating modes for debugging purposes: tes[ mode and process mode . In test ",odi!, all dchugging functions can be uscd Wilhout nostricllOll. You wo"ld selcct thi" for examp le, 10 deblJll blocks w ithout conn~ction to the system, b~~ao,e this can s ignificantly increase the cy_ clic cxe~ution time . 1n pmces.< mode, care is tak~n 10 keep the inercase in eycle time 10 a minimum and th i< usults in debugging re'tric_ lion" e.g. Ihe starns display with progranlloops i, aborted at the return po int. n~bul':;:ing :,nd ,tep-by-~{ep program execmiC>ll cannot be per_ fonned in process operat ion. Test mode is set in lh~ factory on the 57-300 C PUs . You can sct lest or p race .. mooe 0" these CPU s with thc Hardware Connguration on the "I'rotcction"tah . Following thi • . the configurlltion mu,t be compiled again and downl()aded to the C P U. The process mode is set in the factory on the S7-400 CPu s. You ean change the operating mode online w ith th e "Pwb'l'anl E-ditor. DEBUG -.> OPERATION .. displays the set operating modc and offers the facil ity of changing this on line.
You deactivate tho OD signal V"'-PlARL E -.> E~ABLE PERII'HEKAL OUTP\JTS: the module output" now have 'ignal state "0" or the substinne value or force value . You mod ify the JX'Iipheral ootputs with VAlUAll L E -.> ACT!VATE MODIFY VALUES. Yo" ~"" chan ge the modify value and modify again .
\\,ith the Pmgram status function, Ihe progrllm edito r provick:s an additional tcst melhod [or the u,er program. The editor shows you th~ binary signal flow and digim l value, w ith in a network.
You can ,witch the fun~tion off agai{l by "clceting VARlAlILt: -.> £ NAilLE PERIPHERAL O UTPUTS again, or by pressing the ESC key. The 00 "ignal is then active again. the modu le ou tputs au set to "0" ,md the substitute v al"" Or Ihe foree value i, re,c!.
The block whose rrogram you want to de bug is in thc CPU's u,er memory and is called and ed ited th ~r~. Open this block, for example by dOllb le -cl icking on it in lhe SIMATlC M,mager" onlmc w indow. Thc editor is stancd and shows the' program in the block .
If STOP is exited while "enah le peripheral outputs'· is 5till active , all p"ripheral inputs arc deleted, the 00 signal is activllled at ilie transi-
SeieClth e network you want to debug. Activate the Program Statl," function with DEBUG -.> _\1UNlTUR. '-low you ~an see the binary . ignal
2.7.7
LADfFBO Progrum
St atu~
'2 .7 Tcstin& Ihe Program
E· ··· . . . ......... .........
......... ,...... .
"
" --"
" --" "--'
..-...... .-...... . -- ~.
".--0'
• • •
.
.... .j
.,
.
•
>
." . • .. • • • • '•.. .. 0
"._......
• •
.,
.
.,.,'
I
" ' lU..., 2. 15 LADfFBD prtrif1l'" StUUt
now ,n the bl"",k window and you can follow the changes in it (Figure 2 .! ~). You de tine the reprcscntnlion (e.g . color) in the proiram editor with OPTtONS -> CUSTOMIZE on the "LADI FBD" tab. You can de acliv"e the PrOiram Sla tuS function again by selectinlil: D EBUG -. MON· lTOR agai n. You SCI Ihe trigger conditions With D EBt.:G -> CALL ENVlRO)
l\ l odl~'[ng
addressfi
YOll can modify addre.~es in the program 8,ams function. If the address is of dala type BOaL. mark il and selec! DEBuq -+ MODIFY ADDRESS TO 0 o r DEB UG -+ MODIFY AOUM.(SS TO I. With a different data iyp<". ..,leet Dr.sUG -+ MODifY ADDRESS, and = t .... the modified va luc for the marked address in the dia log box displaycd_
Opera tio ns on Ihe
~onta~1
In Ihe Prollram Starns function, you cDn directly mo-d ify b in..f"y input. and bit me mories in the user prOjp"llm by mcan~ ofa button. The fo!lowin" prerequi.ites exist for thi S funClion; ~
In Ihe symbol table. yo u 115silln Ihe inputs and bi t memorieJ with the B"ribute CC (Control at Contact, $ee "Spo..-cial object propenie.· in C hapter 2.5.2 "Symbol Tnble··).
2 STEP 7 Programming SoftW2lJe .. You have enabled operatioJ\!S on the contact in the program editor using OPTIo!'S -+ CUSTOMIZE on the MG<:11CTaZ" tab. .. YOI,I arc online in the program 51al1,l5 with OF.Il UG -+ MONffOR and additionally sele<:t OfJIUa -+ CONTROL AT co:-"rACT. The symbols and addresses of the binal)' inpuIJ and bit memories arc d isp layed n hl,lnons which you Can acc ~ss using Ihe mouse. Addresses programmed "" NO conta(:U or addresses with scanning for signalstarus ·'Z·· Ihen delivCT lhe address status 'T'; addrt"s~s projrBmn ..."d lOS NC contacts or a.dd~sses with scanning for signaZ status '11·' deli"er the slarus .1)'. when accessed_ You can I,Ise lhe CtrllSIrJI key and the mou"," to selcct several add~sscs and 10 access them simultaneously when oper. ating on the COntacl. You deselC'Ct the operands in the .same manner. Monitoring and Modlfyln!: Addrcnes
2.7.11
I)~ t.
If the vHriHblcs to be debugged are present in data hlocks, you can also view and modify them di re<:tly. Se1ectthe data block in the SfMATrc Manag
•
Switch lhe data vicw on in the program editor using VIEW -+ DATA VIEW. and ...,lcct DEBI,O
92
_Mo=R.
YOI,I Can now
VICW
the .~Iual val-
u"" in tbe wor!< memory. and alS(! SC1 (modify) them if =iuired. U.ing PLC -+ DOWNLOAD. download Ibe modified BoCI\1aI values into the work m~mol)'. or usc FILE -+ SAVE to impon Ihe modified values into the omine data management (first switched off OBBUO -+ MON ITOR).
Using ··Parameter assiillment for dnt~ blocks'· you Can directly view and modify Ihc actual values in the work memory of the C PU. You Can also view the actual values here lIlling DEIlIJO -+ MONITOR. and you Can also adjllllt them. U'illg PlC -+ DOWNLOAD PARAMETER SETlTh'G DATA you have lhe possibility for only wriling the actual values into the work memOf}', and nOithe complete data block. Uling DATA BLOCK -+ SAVE you can impon Ihe data block into the omine data management. The advantag e of Ihe appli,ation ··Parameter assignment for data blocks'· i5 to be fOl,lnd in the poSSibility for displaying and panunetcri>:ing data bloch in the pllr1lmeterization vlew_ Prerequisite : the sy.t"," 8t1ribute $7_t""'},parum (1«lInologica\ functions) ;5 SC1. Mnd a parame_ terizatIon desktop is avai lahle, e.g. from an option package_ Figure 2.16 $hOWl! • compari. SOD hetween panuneterizalion vicw and data view Wling an example of the iMta...:c data block for the controller function block FB 58 TCONT_CP from lite standard library PID Comrol Blocks_ Its para meterization desktop is supplied together with STI,P 7.
2.7 Tdtina the Proj.rarn
-'.-
--"'-
,-
..----
J
I
---. -.,... ----- . -••
......... v_.
,.,..
,III •
t
'-
,
,
,
r
"
3 SlMATIC S1 Program
3
SIMATIC S7 Program
This chapu:r ~hows you the srrucrur~ of lhe u~cr proJIT~"' (or th~ SIMATIC &7 -300/400 CPU, starring from lhe diflb-cnl priority c1a~~s (pro8111m ucculioll types) via lhe eo"'ron ....! part. of & user prowam (hlockll) right up lu the ,,.rif\hlcs atld dat~ lyp"". The focu.< of this chapter is the descriplion of block prugrammins .",.iLb LAD and r RO. Following lhi.:I i, a dCliCripuUll uf the dalll IYJICS.
You dcfine lhe structure of the us .... prorm ri&ht bad:: al lhe de8ign phase when y()u .11.;op1 the teclmological and fWl~tiunal C(lndiliOn:.; it ;~ deci~ivc for program creation . program test and ~l"rtup. To achieve eflect ive prugramming. it is therefore nece~sary to d"'·Ole '~;al &ll.ent;on to Ihe pmgr:am stTU<.'turc.
3.1
Program Processin!::
Tile ovendl program for a CPU consists ()f the operating system and Ihe user progfll.m. Tho operating .ystem is the totality of all imtrucHon! ond declaralion' wh ich comrol the 5y~tem re,nUTCe' and the processes u,;nQthc sc rc,wurc.::s, and includes ,uch thi ngs as dala b>l<:kup in tne C,"""l1t ufa power tailur". the actio ~ .. liou of priority daSS<.'s. and ." , on. The orer· at;ug system is a ~omponenl of the CPU I() ",.hich you, a~ u~er, have no wme access. HOw ever, yOll can rclOild the OJ><"I31ing sy.tem from a m<.TOOty card. for instance in the event of a pmgt1lm update. The Us('T program is thc total ity o f all instn1Ction~ Hnd ded,Il
3.1. 1
P rollr am
l'roc.~ssj n lll\ftlhods
The o.1.'ieT pTUgram may be comj>Of;Cd of 1'1"0gram sections which Ih~ CI'U processt'S in dCpol'ndet1ce OIl cmain e""TIts. Such an event might be the Starl of the .ulomal;on sys1em, an tnlerrupl, ot detection ofa program errot (Figure 3.\). Thc programs .\located to the e venu arc divi ded into priority clllllses. which determine the program p~iDg ortkr (mulUIII inlerrupubility) ",hCll ""venl.l "',·.. nI5 oc"ur. Tbe !owc
-.
hand ling routine and rer~n\s 10 the muin pm-
A specific organi~ation block (OB) is allocaled 10 each even\. The urgani1.&liOl1 bhxk.s rcprcseal the priority classes in Ihe Ui .... prognom. When an e,...,1t uceutS. the CPU invukc¥ the aWilloo UIg!ll1i7.alion block. An UIW"lizalion block i~ a part of a u.er pTOjlnil.m ",hicb yUIJ your
The main program is in orgamzat,on block OR I. u'h ich the CPU alway. procH.oe~. The Sill" ofthe u~er progrnm i, identical 10 Ihe first nCI,,"orlc ill OIl l. Airer 08 I ha£ been proce
,
I
Pow. on
I
L /
,
1
,
0
I C,..
SI~nup
""""m
~ • •~ M al ...
I
•
-
•
/
'""""'"
•
•
~
in(ellupl
•
OperaUng
,
•
I Error ha ndllnq
~
g,am
,
~-
~
p ro_
I
I IntorrupturoAee
routine
) ,
•
•
.~"'m
FIlM .. 3. 1 Mnhod. or Prnct.-.
atinj system on.! , "fter calling fOT Ihe execution of v ariou~ operating 'Y'icrn function., ,uell as th e t,pd a!i ng of the proc"" images, il once ~gai n calls OU I. Evcntl wbich can intervene in the program om: inl('ffilptS and elTOrs. [nferrupu can come from the pn)Cus (bardware interrupti) Of from the C PU (watchdog ;nt",",,-plS.. timc·of-day inl~"T' ruplS. CI"',). A. far •• ...-ron are concemed. I d istinction ;s made bctwe= synchronou~ and
inlcrrupl tim! was
I!~ncrated
\)eCltU:IC a module
was bdng replaced. A
~ynchronou.
error is a n error C(I llSI'd by pro-
gram pnxcssin g, such as acceuing a non"")I;sI~nl address or a data type: eonversioll error. The rype ami number of r<:rorded evcms and the
asscx:;alo:-
asynchronou. errors. An asynchronous error is an error which ,g independent of the p rognun ..,an, for eKamplc
failure of Ih~ p
J. I .2
P r] " r lly
Cla.~lfl
Table 3.1Ii.l. Ihe availab le SIMAT IC S 7 organization blocks, cach wilh il~ priority. In Solne
3 SIMATIC S7 Program
priority classes, you can change the assigned priority when you parameterize the CPU. The Table shows the lowest and highest possible priority classes; each CPU has a different low! high range; a specific CPU occupies a section of this overview.
warm restart, hot restart); monitoring of Ready signals or modu le parameterization: maximum amount oftime which may elarsc before a warm restart f>
Organization block OB 90 (background processing) executes alternately with organization block OB I , and can. like OB I. be interrupted by all o ther interrupts and errors. The startup routine may be in organization block OS 100 (wann restan), OB 101 (hot reslan) or OB 102 (cold reslart), and has priority 27. Asynchronous errors occurring in the startup routine have priority class 28. Diagnostic interrupts arc regarded as asynchronous e rrors.
> Retenti"e Memory Numb-er of relent;ye memory bytes. timers and counters; spec ification of retentive areaS for data blocks (>
You detenni ne wh ich of the available priority classes you want to use when you parameterize the CPU. Unu,ed priority classes (organi2ation blocks) must be assigned priority 0
3.1.3
Spccificatiotu for Progra m Processing
The CPU's operating system normally uses default parameters . You can change these defaults when you parameterize the CPU (in the Hardware object) to customize the system to suit your particular requirement<. You can change the pa .... metcrs at any time . Every CPU has its own specific number of parameter settings. The following list provides an overview of311 STEP 7 parameters and their mo,t important settings. f>
Geneml Name of CPU, plant identifier, location 10. scllings for MPI interface (if the interface is not combined with DP). comment
f>
Startup Speci!ies the type o f
96
Memory max . nwnber of lemporary local data in the priority dasses (organ ization blocks): max size Oflhe L stack and numberofconununi cations jobs
f>
Interrupts Specification of the priOrily for bardwarc interrupts. time-delay interrupts. a.
f>
Time-of- Day Interrupts Specification of the priority and assignmems of partial process images: spec ification of tbe start time and periodic ity
f>
Cyclic Interrupts Specification of the priority, tlte lime cycle and the phase offset: assignment of pania] process images
I>
Synehl"(lnoi.l~
cycle interrupl< Specification of the priority: a.signmcnt of DP maSler system and partial process images
c>
Diagnostics/Clock Spec ification of the system diagnost ics; type and interval for clock synchronization, correction factor
The relevant organizalion blocks must be programmed for all priority classes used; otherwisc the CPU will invoke OB 85 "Program Proce,sing Error" or go to STOP. For each priority class sclcrled, temporary local data (L stack) must be available in sumcient volumcs (sec Chapler 18.1 .5 ""Temporary Local Data" for more details).
Cycle/Clock ~femory Enable/disable cyclic updating of the process image: spec ification of the cycle monitoring time and minimum cycle time : amount of cycle lime, in percent, for communication: numbt."f of the clock memory byte: size ofthc process images
(>
(>
Prolection Spec ification of the protection level; defining a pa
3.\ PmgramProcessing
T~bl~ 3.1
SJMATJC S7
O,gan i z.tiOI~',"'~ :::"''-------------T---';;;;;;;;'--Modifiable .
, ,
,.
0"
modulos
16 to 2J
Wi th ... tu>. update
PROFlBVS DrY I "
,or mOOe
tech no1_
"Co,. ' ~ I
In the c""" "f lo., of redundar>ey "'"'",.,
OB
~5
OB
~8
toOB ~4, g6.g7
:~~c c. c
2 to 26 2 to 28 2 to 26
"'"
1n th e C05e
ORRI
" "
.
26 2) 2 5 2) 25 ) '
Sloer",' .
failure,
No
2 <026 24 to 26 No
'"
N"
"
the em::>'"
t>
integrate
On startup. m~ CPU puts th e user parameters into effeet in p la<:e of the defaults , and they rem ai n in force until changed.
t>
Communication, Definition of ~o"nection reSourceS
Proll:rllm
"" Web Activation of the Wcb 8crYer, language se_ lection
len ~.'th,
memory requi,-., menls
Th e memory requirements ofa compilecK in the SIMATIC Manager, and then seleet the " ".neral _ Part T tab us ing E DIT -j.
3 SL\IATIC 57 Program
OIUEc r I'ROPERTII!S, you will Ix: pruvid;;d wilh the load and work memory n:'Iuiremcms for this block.
tied by the systt= function DilL.
The length of the uocr progrRm i.' li>ted in the propert;"" of tile offline BloeM conta in er (selecl Bloch and EnlT ~ OBll'CT PROPER·CIES). On the "Blocks~ lab you will find the data " Size in ..."OJk memory" anod "Si7e in load memory".
MOdule ill
NOle that the configuralion data «y
~
M ODUll
I-" fOK."t~·
noy.;, " Memory" tab. Chccuum The progt1lDI editor grnerates a eheel
"\05. The c1l<:cksu m oflhe uscr prugnun is genemlcd from the program code and Ih'" default and ini. lial vai u"'5 of the data blocks. The writing of dotta add",.,"" in the won memory ("ct~al \ 111ues) does not ch....nge the checksum. Th~ checksum i ~ only adapted when the data blocl.<. are uploaded to the "mine data management, when the actual va lues become the ini tial values. Th;~ al90 81'(llies to the data blocks aeneratcd by a ~ySlem function. If a data block gcnerRled by S}'Slem functions i~ "'"tlen or d eleled. Ihe "'hecksum ;s nol changed. The checksum is adapted i f a pro· &mmm~-d (loaded) diIla block i. deleted. or if Ihe inilial values in the loud memory me modi·
'"
S ~'C
84 \'lR1T_
Innov.I~...J
S7-CPU" PROflBUS DPYI slaves and PROfL'I ET 10 de'~ces am :mppnn funclions for idenlifica.tion &. maimen= (I&M f\uu:uons). For example. you can provide a ~t.a tion wilh a higher.level itelll desillnatiou and ft 1(>(&lioll lD and evaluate it laler in the program. The higher.level ilem designalion ;s used to i.l entify parts of the plant un i 'lU~ Iy a~~ording 10 their function . The locati on 10 is part o/' tlte it em designation and de~Titx:s, rur cxample, the precise localion of. S IMATIC ocvicc with_ iII • pruc<:ss pl""t. To emer the 1&1,,1 data, ~elecl the module in the Hardware Configunuion, Ilten select EDIT ..... QnJECT PROPERnF.S, and then - wi lh an appropriately design:d module yuu can enter the higher-level ilem dc~il:lnU liun lind the location lOon !h~ "General" lab or tbe "Identification" lab, In online modi:, you se lect the module and C~n then exchange the I&M dau. oclween of· fline dloa managemCIlI anoJ th~ module with PLC ..... DoWNLOAD I-IOI)I.:U' IDB'Tlf1CAnO"l or J>LC ..... UPLOAD MOOt..LE IDE:YIlflU,nO:-l TOrG. To anal)?e the r&M dala, us~ SFC 51 RD· SVSST 10 read Ihe system st,ttu . lisl with the iy.t~m status list ID l6#OIIC Index 16#0003 for Ihe hiiher-leve! item
3.2
Blocks
You can d ivide your prQllntm inlo a:s many s~c l iuno as yO\1 wanllO iu ortl~r tu m ilk" il easier to
read and u.ndersmnd. The STEP 7 prowamming laD!'U~g~ •• upport this by providing the neceSsary funetiuns. Each program seclion should be !
3.2 Aloc ks
3.2.1
Rlo ck TYI'es
STEP 7 provides d ifferent typt".' o f blocks for dilTe rent tasks: >
[>
I>
Uoer blocks Bloch conta ining user program a nd u ser data Sy,tem block< Rlnch containi ng system program and sys tem data Standard blocks Turnk ey, off-the-melfblocks, such a, driv_ ers for FMs and CPS
Us~r
bloc k s
In extensive an d complex program" <'struclllring" (dividing) of the program ink> bloch i, recoI!1Tl1cn dcd, and in part necessary. YOLl may choose among different typ~s of blocks. depending on your application:
Orx""izar;oll Moe,,",' (OBs)
FunCiion.I' (Fe's)
Functions nre used w program freque ntl y recurring o r comp lex automati on functio"". They can be param~lcrizcd. and rctum a val"c (cal led the funct io n ,·alue) to the calli n g blu"'::. Th e function value is optional, in addi tion to th e function value , f"nct ,ons m"y a lso have o ther output parameters . Functions do not store intor· mation, and have no a ssig n ed data block.
Da ra blocks (DBs) These blocks contain your program's data. Fly programming the data b locks. you dctennine in whic h form ~he data w ill be savcd (;n which bl oc k. in what ortl~T, and in whm data type ). There are two way" ofu,i"g data block s: as global data bl o~ks and as instance d"ta blocks . A globa l data b lock is, so to sp~a k . a " frcc" data block in the user program. and is nO! allocated 10 a "ode block. An instance data block , how_ e,"er. is a,s igned to a func tion hlock. a nd ,tores part of that fun Clion block's local data .
Thesc bloch serve as the interface between operatillg .yo>tem a nd user program. The CPU', op<-'nning systcm calls the organ i ~ation blo~b whcn spec ific events occur. for example in the eve nt of a hardware or timc-of-day interrupt. The ma in prOgrdm is in o rgan;7.ation blo~k 08 I. Thc other
The number of blocks per block type and the length of the hlocks is CPU_dependent. The nllITlber or o rganization block s, and their block number.,. are fixed ; they an.: assigned hy the CPU', openoting system . Within the specitl cd range. you can a"ign the b lock numbers of the other block typ~s yourse lf. You also have the option o f assigning cvcry block a name (a 'ymbol) vi" the symbo l table, then referencing each block by the mun e a>signed to it.
FUllction blocks (FE .•)
Sy.tem h loeks
These b locks are parts of thc progrnm w hose
System bloch arc compon cnt~ of the operating sy5lem . 1b ey can conta in programs (system functions (SFC,) or system fun~1:ion blocks (SFBs)) or dala (system dma blocks (SDFls)). System blocks make a ncmtbcr of important sy>lem fu nction s acces. ib le to y ou , such as man ipula~i ng the internal CPU dock, or various cotnmu" ' ~"tions f"n~'ti ons.
calls can be programmed v ia blo~k parameters . They have a v ariab le memory which is 10~atcd in a data b lock. This tlata block i, pemlanently a ll ocated to the functiol1 block. or, to be more precise to the function block call. it is even possible to a
You can call SFCs anti SF8s, bu~ you cannot mo dify them. nor can you program the m yourse lf. The blocks themselves do not reserve spaec in uSer mcmory; only the block: calls and (h" inSlance d ata blocks oftb e SFB . are in user memory. SDBs contain information on such thing' a s the configuration of the automat ion system or the
3 SI"tATlC S7 Program Table 3.2 Numher range, lOr sy" e m dat> bl,)(,k,
, overwrite.
ti
II
coofig-
"
e .g . a,., ign mont of logical
"
"
, rOT HIf and
parameten·""tio" of the modules. STE'P 7 itself and manages the., e block s. You. how~vcr, dClenni ue their contents, for instance when you configure the stations . As a ru le, SOBs are located in load memory. You cannot Ol"'n SDB" and ean only read them from your program u,ing speeialsy stcm bloch. e ,g. when rmramelerizing modules. gencrat~.,;
Double cl ick the System bloch ohject in the Blocks container to d isplay a list of current syslem data blocks generaled by the Hardware Configuralion to
Chapter 25 "Block Librarics" con tain s an over· view of the ,tandard b lock s s"p phed in the Standard Library.
3.2.2
Block Structun.
Essentially, code blocks consisl of three pan, (F igure 3,2): ""
Th~ block header, wh ich contain, the block propcnie., such a s the block nam~
;>
The declaration se<:tion, in which the block-local v:ariablcs arc d~darcd. tha t is, defined
t>
The program
Standard blocks
A data b lock is similarly structured:
In addition to lhe functions and funClion blocks you crealC yourselt~ off-the -shelfhlocks (called "standard blocks" ) are a lso available. They can eilher be obtained on a .' torage medium or ~re contained in li braries deli,' ered ~s pan of the STEP 7 package (for example lEe function;;, or functions for (he S51S7 eotwcner).
""
1>
n,e block header contains lhc b lock properti~s
1>
The dedaration ,ecliotl cOlllains the dcfilli(ions of the block-local va ri ables, in this case lhc data addrcsse, Wilh data type specifi cation
name, Data type:_ In~;aliz . ~on: name. Darn type'. In;!;alizatTon:
PrOfJrlIm
BEGIN Program
END_Block Type
Data block. In"",m"ntal prog r8m ming
Data block, .ource-orlented prog ra m m'"g
•
I
Block I>c"dcr
S TRUCT
Decl6relion Address
INama J
-,-
''''
In itia l value
"!!me , Data name: Data
t ype:~ tyP": ~
...
InrualizBtiQn: Initialization;
END STRUCT
.. .~
Fi ~n ,..,
l>
-
I
DATA_BLOCK Aadress BJock h9lJder
.
I
BEG IN
I
name
I
END_DATA_BLOCK
.~
Initializa tion;
-
II i
,
II:
3.2 StructUTC ofa Olock
The initialization <""lion, in which initial values can be sp~cified for indi vidual data addresse"
Tn incremen tal programming. the declaration St:ction and the initia]'>alion ,ection are comh ined_ You de line the data addrc>ses and their data types in the ··declaration v;.ow" , anJ you ~an i1lilialize each data address ind ividually in the "data view".
3 .2 .3
Block Properties
The block properties. or attrib ules. an.: conta; "ed in the block header. You can view and moJify th,"" b lock pmrc1'1ics with the me tm command EDn --jo OWRT PROPERTIES ill the S I"'lATIC Manager when th~ bl()~k i~ selected. or w ith Fn.r. --jo PROPl'RTJES ill the l'rogram Editor (Figure 3.3).
w,
3 SIMATIC S7 Program
,-....-~
(RIO<
ji5;-' Ifij .~ ..... _ ,"_. f~ ""' _"""
G"' od ~ '-""'
,,-p,",
~
' ~991(1lll " '''''
', I211l ... ""·UW ....
,-
~O_
"'""-""" "'.... w_
_
•
•
J
_ _ ~ "" ....c rr 0____ ' ~ ~"'"_ r
W", " ",,",
"General - Pftrt I" tab Under Nume. this tab con rain s the block '. absolute address with block type and number, as we ll as the symbolic name and symbol comment from the symbol1able. In the caSe of function blockJ;, an indicat ion next to the name shows whNher the block has a multi instance capability. lIthe m,dli_inS'(Jnce ""pilbili!y is switched on, '''hich is nonnally the cas~, you can call the block as a local instance. and can al", call further function blocks with multiinstance capability with in it as local instances . You can deselect the multi-inslu" ce capubility when creating the function block; with a .oure eoriented program input, Ihe keY"'ord for deselecting is CODE_VERSION I . The advantage of " function block "without multi-instance capa· bility" is the unlimited application of instance data during indirect addressing, whieh is only of significance with STL progranuning. The tab also shows Ihe crearion language oftbe block (which you set wh~n crealing the block),
'"
and the memory locations of the block and the proj ttt. The program witor SaVeS the creation or modi· fication date of the block in two time stamps: these are the block pararnC!ers and Ihe 'tatic local data for the progr.m code and Ihe interface. Note thaI Ih~ modification date of the interfac e must be equal 10 or smaller (ol der) than the mod ification date of the program code in the calling blo<:k. If thIS is not the case, the program editor si gnals a "time 'lamp conflict" d uring output oflhe calling block.
The ,ommen t d isplayed consists of th~ block title and the block COrruncnt wh ich you entered when programm ing Ihe block. "General _ Parr 2" tab
Thc N am e (Header) displayed on this tab is Ihe block narnc; il is not idemical to the symbol address. Diff~n:m blocks can have the Same name. Us ing Family you Can assign a conunon feat ure (0 a group of block s. The block name
3.2 Blocks
and family an: displayed when insening blocks if you sc lecllhe block in the dialoll; window of the prollram element caTa log. u..e Author to cnt~r the namc ofthc block's crelltor, The namc, family and author may have up to d¥ht chameICrs cach. commencing with a leller. The letters. d igits and the underline characler arc: permissible. The Venion is ente~ wllh N 'O 2-dig;t numbers from 0 to 15. The len~h dala slwwthe memory allocation for the block in byte~' ~
Loc1l1 dam: allocalion in the local data stack (temporary local data)
~
Me 7: size of the block (code only)
~
Load memory requi.rcment
~
\Vork memory requirement
A block occupies InOI"I: space in the load memory 8ince the data 001 rc:levant 10 processing arc: oaved here in ~ddition.
The Klto",-how proleCli(m Huribute is used for block protection. If a block iH know-how.protected. the program in th at block can not be viewed, primed out or modified. The Editor shows only the block hcaderand the declaration table with Ihe block pammeters. You can assign \his aunbute during sourcc-oncrlled inpul orthc block with the key",oro K.,-':OW _HOW_PROTECT, When you do th is to a block, no onc can view the oompi\oo version of that hlock. not even you (make sure you keep the sou...:e file in n safe place!) , Th" att ribute DB is w.-ile-profeCfl'd in Ihl! PLC is an aUribute for data blockionly. II means that you ean only read that d ata block in your prog"un. Output of an error mcssalle pre"CTlts the overwnting of the data in that data block _The write protection applies (() lhe data re1C"llIIt to processinll (aclual values) in work memory; the dala in load memory (inilial "alues) can be o'-crwritten e"cn iflhe data block is write_prot~cted. Th is write protection fearure mu.t not be confused wilh block protection, A data block with block prote<,:tion can be read out and ..... ritlen 10 in the user program, bUI ils data ean no longer be ... ie .....e<.! wilh a programming or operalor monitoring device. The attribu:e DB is ..rill!' pro/eeIM;n Ihe PLC is switcbC
program inpul for switching on the write prot"""lioo is READ_Ol'o."Ly' The block header of any staodl.rd block which comes from Sieme"" conluins the S/(Jndaro block anribute, Data blocks can be assigned the Unlinked attribute. Such dala block5 are only present in load memory, and are not relevanl 10 processing. Since their data are nOt locale
is
UNL~KED.
The No" ,-,:tailt attribute means "nan-tctentive" and is assillned to CPUs dnigned for this for dat;! blocks. If Non reral" is s ..... itched 00 . Ihe d ahl block Ir.msfef!! the initial vBlun from load memory ro WorK m~mory in the ev~nt of a power ofton and with a RIY.-l-STOP transition (response as wilh a cold restart). If Non ",wi" is switched off. the corresponding data block th~rc:fore being ...:u:n!i~". il retains illl actual vRllIe$ ,n the Client ofa power oft7on Bnd with a RUN-STOP transition (response a~ w ith a wann reStllft). This attribute is switc hed off as .tandard. bUI ~an be changed at any timc using the program editor. Th~ hyword with .ou...:eonented program input for switc hing on this attribute is NON RETAtN . Blocks saved in the Program Edilor w ilh the menu oommand FILE -+ STORE READ-O"\"LY for reference purposes. for ell ample, receive the block property iJkJck read-on!),. These can be all eodc blocks. data blocks, and U!ICr-detlned data typcs , Tbis property can only be se t with thc Program Editor. and thcre i~ "0 keyv.'ord for source-oriented progT'll.mminS for this purpo.e.
"Calls" la b This tab shows a list orall blocks called in this block with tbc lime stamp$ for the c;ode and the interfaee. With in.lance dala hloch, the basic function hloc k is shown here togeth~r wilb Ihe
.0)
3 Sl\lATlC S7
Jl'ro&nm
loc81 instances (function blocks) call"" in thi, in each case with the time stamp:; for code and interface_ in!tan~( ,
~ Atlrlb .. u.~
tab
Blocb may ha"e ~y~tem ~llributeS. System auribulell rontrol and coc:m:iirulte functions betw~n applications, for example in the SIM i\.TIC PCS 7 control s)'Sttm.
Howe,.. r, Ihe interface connict generally as a "time stamp conniet" caD alw have other caUSe'_ It aIM) occuu if a call«l or referenced block is younger than the calling block. Example. of the OCCUT1"'CnCe of time stamp connim indude the followilli ' descri~
po
TIle inttTrace of a called block is younger Iban the code of the .alhng block.
po
The inl,rrfiJce inilialuation does not agrtt ,,;Ih the block internee.
3,1.4
Block In tufacc
The declaration table cont.aiM the interFace of the block 10 the rest of the pman.rn_ It consim of the block paramCters (input. ou!pUt and in. OUI parametcn) and al", - in Ibe case of~ lion bInds - the .Ianc local dalll.. The temporary local data, wbich. do not baSically belong 10 the block interface, are also bandied at this point. The block interface is defined. in the intcrfa.e window when prognomming the block, and i. initiali~ed with variab les when the block i. called (~ce Chapter 19 "Block Par.uneIen;"). The Program Editor checks that the block
I>
A func:tion block ;5 younger Iban its instlnce data block (the in stance data block is general«l from the interfuce d:scription of the function block and should thO'Iefore be }'ounger than orlhe ~me age as the function block).
> A 1()C1I1 ;n.1III•• is younger than the calling instance (affect. function blocb).
> A user data type UDT is )'OWIgCf than th. block who:se ">riables an declared with the UDT: Ihi~ can b<: any block including a data block or OIlother UDT.
Con'Kling innlid block
<.II~
paramder initialization in the caUed block agrees with the interface of the <:&B«I block. The Editor uS<:> the time stamp for ws: the interface of the caBed block must be oldtT than th e code i'l the caUina block, thilt is. lhe Lost interface modifi c~tion 1l1u!t h~\"e been made prior to integration of the bl..""k. The Program Editor updates the interface hme stamp when the 'lUmber of parameters chanlles GT ".hen a dlrta type or a default value changes.
Tbc Program Editor ~uppons you in different rna Mers in fmding and CQJT«tlng in~a1id block calls. Sc-e the next s
TIm", , la mp .,... met
"'hen cbanglog the name and type.
You can ch""k bloc>:: ,ails which ba\"~ b~come invalid witb the bl..""k opelt (wilh the Cllisor at ~hc invalid block nil) using the menu com !II&Ild Eon ...... BLOCK CALL ...... UPDATE. Block calls can berome iD\"lLtd follo"ini insertion,
dtlC1ioo or shifting of block paramelers, or A time stamp conflict tXC1.tR whnr. the interlac.
of the c .. lled block hal a later Ume jtamp than the code of the calling block. You "ill notice a time ~I ru.np conflict ifyOll open an alC<"ady ~om_ piled block again. The f'T()aram Editor then indicate:; the incorrect block call m red. A time ,;t.atnp conflict can be caused. for ""ample, if you modify the in!erU«5 of blocks thaI ~ Ilready ealled in orh.,. blocks, (It" if you com_ bine blocks from different programs into a n"" program, or if you ~ompilc a !«lion of tM nvcnt.ll program with ~ sourcc file.
""
With EDIT ...... BLOCK CAU. ...... CHAl
calls from function blocks imo local inst~nce calls or inlO calls "'ith data block. following mOS'iibility i. provided by the menu command FD...E ...... ClIECK AND UPDATh ACCE~S."The
in,-ahd block callI in an opened bhxk iICC thrn updated orpresCnted for modification.
Ch~cldng
hloek consistency
11'e Program Editor only itldi calC8 a ti me stamp confli~t when you open a block containing a time 'tamp conflict , If y ou want 10 chcd:: an entire pmgram, you can u,e the function <'Check blod.:: consi stency'" in the SI.\1/ITIC 'vfanager an. This purges a majority o f interface conilic," and direct, you to the program loca. tion, thaI re
To earry out a con,isteney check, sdcct the Blocks container in the SIMATIC Ivlanager and !h~n EOIT --> CIlLCK BLOCl< CO,SISTfSCY, lfa call tr~ e is not displayed in the " indo",- e .g. bec~l1SC
lhe pTogram ha, been compiled u ,ing version of STEP 7, .elecI PROGRAM --> COMP I ~E in this w indow, an
earli~r
I' lca,c note that after check ing the b lock ~on8is" t~n cy, the instance data bloch and thc dam bloch g~nemted from the UDT are assigned t he initial value, aga in in the compiled pro"
""m,
The Program Editor displays the progre ERRORS A'ill WARNINGS). "lbe e ons;s t~'ncy check CaJI]101 be nscd on progr~m s in li braries,
Thc dependencies in th~ case o f call ~d or referenced blo~b are displayed in the fonn ofa tree d i"gram (t'igure 3. 4) , You can choo, c bctw~en the following two representations:
••'"",,''''L ..'001· [ot """I ' [DO ~l
•. ." ~,
·... _do',,- [<>0 """I
....u ..... [1>1'_]
"0"""""
~o
'
_",",,' [M ' _J ..... . "oj' [:0""'«1
(0'
"'«I
'(~[""
,'
."
",
- . """-" I'" '''",I "~;:~ [''''I
'i'
0 0., '" Q '""" :;c.
..
•~
," [C<'-I ~'-I
,
:eo &t~ ]
o oCat"Ol '"," -"""..,.l"'l[""I .Q o"",COt ........... _ L>"'l _
0 ""
,
COl'
,
"."..,..' [1'' '....1
·... "-'""'"""'· 1''''1 ...... :=1
a """ _1....""' .. · _
•
-I
o CO!
0 "'"
.,.•...,.,. I'" ' ''.-1
.p". . . ' 'w·[RO) .F"......'
~o..o'r_'''''''''[MO) _
.P". . . ' [nol
I
.".......""... ' :""']
( "' ~ l
ot'" ('" """'~l OI' !"I':
Fi~Dr~
3.4 Exomplc of!h< Repr< oon"'tic" of the ·'Check Block Consistency" [kp
]1)5
T10e reft;thcr lree vie w displaYllt~ e lJepe nden. a similar wily !o the progn.m Slrutlure: Oft rM left are the tallin& bloch. funher 10 II>c rigtu an; the blocks tailed in the blocks on tl>c lel't Example: inSl:lncc DB 20iFB 20 ill tallffi in O B I and local in.'lIlnccs FB 21 and FE 22 are callffi in FB 20.
vided with the propr;nles window o f the block. On me "Genenol _ Part I" tab. sclect the number of the block under Name and the language "LA!)" or "FRO". You can entCT rhe remaining anribulC1l11ler.
aa1 ...
The dependency tree view di,'plays the depcndcn<:: ics starting from all called or rderencffi blnc b. Thcy arc located in the left_lIftrnl tol umn. and the calling blocks arc ilStffi 10 tne ri&ht or thi5. bample: FE 22 stores its data in instance DB 201FB 20 that is tallffi in 08 L It alo;o has its own DB 29 and it iscal1ffi a, a local inStancc in FB 20. The dC lcnnincd infonnation is displayed in compact form by symbols. An e~chllnation marl:, for example. indicates thaI the obj~"Ct cllused a time Slamp conflict. A whue cross on a red background Ind,cates that the ~SlXiated block must be recompiled. If you select a block in the tree diagram orin the ..,utpot window. you can edit it witn eDTT -+ O PEN oBJ!cr, e.g, COJ1"C'Ct an incorreCI call.
Programming Code Blocks
J,J
Chapler 2.5 "Creating Ihe S7 Program" contains an introduClion lO program creation and I<> operating the program editor.
3.J.l
ap.,nln g Blocks
You begin block program'mnll by oflemng a bloc k. Open an exisling block either by doublecli cking on the block in the SIMATIC Man_ ager " project window or by ",lectinfj FU_E ..... OrEN in the program ffiitor.
Irroo open. compilffi block in the Rlocks contai...,.., e.g. by double·docking. it i$ open for incremental programming. This is the case borh with omine and ol1line progmmming. 'f lhe ~Iock doc~ 110! yet exist. you can grnerale it ;11 the following ways: t>
In the SI MATIC Manager by selecting the 81.,.,h ohJ«t to rhe left half of the project
",-indo,," and generating a ncW block with ll'o."SERl -+ S7 aLOCK -+ . You are pro-
'06
t>
1n the Edilor "'ith menu command FILE -+ NI:\\. which displays a dialog box in which
you can enter thc d~sirffi bloc k untler objecl Aft~r clo.ing the dialog box you can program the comeDl~ ofthc block. The Pmgram Editor uses the language set on the '"Create BlocI<'" lab uDder Omoss -+ Cus-
nom".
TO\fl7'F.
You can e!ltcr the in f<1rmntion for the block huder when yo" generate \he block or you can omtcr the block anributes later in the Editor by open,ng the block and selecting lhe menu com' mand FILE -+ PIUJl'ERTII:.'1.
3.3.2
m oc k Windo"
The progmm ed itor shows th e variab le decl am • tion table (block param~!ers and local data) and Ihe program ....·indow (code and comrmnts) for an opened code block.. The pro~ elemenls cannol be additionally dlsplayffi in lhe n"~..._ ,ie'" "indow (Figure l.S). Va rl.blr declaralion tahl e The variable declaration table i~ in \ h<; wir.t.low abovc llle progrom window. If il is DOl visihlc. posilWn thc moll.'" poinlcr 10 the upper line of demarcalion for the prQgnIm window. dick on
the left mou~c bunon wilen the mou.., poimer chnwc5 ils form. and pull down . You will sec Ihe over"iew of the types <.>fvariah1c on the !efl . and Ihe variable declaTll.ll..,n table on the right . which is wbere you define Ihe bloc k_lncal "Bri_ abks (see Table 3.3).
In order to declare a "ariMbk, sekcl il5 type;n
the left area. and filJ in the uoblc on the righl. of variable can be programmffi in c\Cry kind of code block. If yo ,) do nol usc II variable Iype , Ihe cnrr<:~potlding line remain! emply.
,",01 ~"cry type
The declaration for a variable consists of the name. the data type. a dt-fault >"alue, if any. and a "ariable commeDl (opIiorul). Notall variablC1 ~an be 85signffi a dcfuult value (for instance, il
3.3 Progro.mming Code B loch
'jo"
_n'"" ,,,' __ ~.~ . ' '''' .... , ...".. .......
.. ••
,~"
,.... ,-,. ,-, ,~
-......_.,..... ..... ,. ._. .w.·_._... h.' _
,
....--.0_,
,_. "... .
_ _ _ _ _ ... _
• • ___
. ~_.
M __
., ... _ . }
~- - " ......""
t· ]litu ....
3.~
:3
l:JIampl" of .,. Op..ned I AD Block
is nOI possible fm t"mpomry local dam). The default values for funct;on~...,d funttion blocks are described in detail in Chapter 19 ··Block. Pllmmc1crs'".
BOOL Or BYTE variable at B byt" boundary and II variable o f anolhCT datB type at a word boundary (begi nning a1 a byte with an even address).
The ard"r of the declarations ill tade b locks is fixed (u ~hawn in Ih" tnbl ... abo\"e). while the oruCT within n variable 1)'1'" is arbitrary. You can $8\'" rOOm in ~mory by bundlIng biruuy variables into blocks o r 16 and BYTE ,'ariabies inlO pairs. 111" Edilor S!O~ a (new)
In the program window,)'Qu will see uepcnding on thc Ednor'. dcfauh Serling' the fields for Ihe block li lk and the block commen! anu,
ors
Table 3 .3 Variable Type. in the
O~d.rarion S.~llO"
Vatl""l. Type Input pat:amete",
Oed. .... ti""
OutP"t peramet"'"'
OUT J.1'. _O UT STAT
In-aw parameters
St.l ic 1<>Ca 1data
Temporary local da .. Fune
P" .. ibk io moo .. Typ<'
"
"""
RETUR..'1
K K K
08
,e ,e
,.,. ,. ,. ,.
'"'
3 SL\tATIC S1 Pr<)¥f'l'II
if il i, Ihe first I>('twork.
th~ fi~lds
for tbe nl:l-
wort: tide. the network cmnm~n:. and the fkld to.. the prognm entry. in the program SCCIion 01 ~ode
block. you control the di'l'lay of comand ~ymbo ls with the tllffi ....-ommunds VI !!W ~ DISPLAY WrIll. You call chan~e the ~ ; ze of the display w ith \IJ.Iow ..... ZOO'l I);, V IEW - ) ZOOM on ,md VJ..Io'1 ~ ZOO\! r ",C-
..
ment~
'"' O"frvl~"
JJ.3 The
ov~rvie\\'
clement
Window
window contains :ho: program owd the call rnue=
~PtIllO¥
If the ov~rv,eW window is nol visible.. feteb it onlO Ihe sclft'n with Vl:Ew ~ OVEIl\J..Io\\S or w;lh INSI:.RT
~
r J«)(iR.·\ M U.£ME"oiS .
Tllc o~'cr\';ewlI arc p~senlcd in a S..-pal1lle window which you can ""dock- at the Mil" of the .-..I ilor window and also relea,., .eain (doubledick in nch c85e on the title bar of lhe oHTview window) .
automatically. brginning with 1. Each block can accommodate up 10 nL'1"ork$. Yo:! may gi"c each network a nelwori<. IIlle and a nelwon: cornmenl Durina ed,tina. you can KI«r ea, b lI"twor~ drrcctly wil h the Illenu COJlUn~nd l:'DlT ~ Go To --; .... ,,~
m
To enler the prob'fam code. cI iCKoncc below Ihe window for the n<;!wllrk comment, or. if Y"u have <;(1 "Oi'play witb C"mments", click OnCe h<:Jo" the ,haded area ror nC'1work comment,. YOII ... ill SCe a framed emply ... indo.... You can begin C'IIlering yom PIDIlram 8n)"b= within thi~ ,,'indl.lw. The chapters heJo" sbow you "'hat a LAO e = t path or an FRD IOllie operation looks like. You program a new
n~N..ori<
l"1:TI'o·ORK. Tbe Editor then
" 'ith L'SERT ,"~c-n, In
network behind the curremly selected network.
Program dCmcn l$ catalog The prollnlm clemenl~ call1l,,,,!,' suppon s prog"""unini in LAD and FRO b} pro"idinllthc available graphic el~m~nl5 (Fign~ 3.$). You caD dnlg all program elnn=ts into the proJll1lm windOW u~inlllhc mou;;;:. In addidon, ;I!;,;UI the block.> already loc.ted In th~
omine JJlocL conlain~'T. as well as the aln.:ady-programmed multi -iru.hmcc5 and the svail abl~ Jibrarie$. Dy dickina, with Ihe right rna U-le buttoo 00 n block or a bl<><;k I)·pc. )'OU cao select wh~Iher the bloch are 10 be ""'rted aocording to Iype ~ntl numbct or accordini 1() Ih~ block family. Callstru,lurr 'The call struclUre shm,", th~ block Ilicrnrcby ID the cumnt user prog:rnm. You are ,ho"'D the call .:t1V;ronIllI..'Ill of the currenliy ~ned block toge~r with the blocks used.
JJ.4
Pro~rammln~
l\"crn'orkt
You can divide a LAOIFBO pmgram intO networks which each repres~nt a eurnnl p~th or s logie oporul ion . The Editor numbers the nct-
'""
~
eml"ly
FI"u ~ 3.~
Pro!!"", !':l
3.3 PmgraTlltning Code Bloch
You need nO! terminate a hlock wilh a speeial statemem, simply 'lOp making emries. How" ever, you ~a" program a last (empty) n~t"'ork w ith the title "Block End", providing an easily seen v isual end of the block (an adYamage, particularly in the CaSe of ~x~ept ionally long blocks).
window). A dialog box appears automatically and he re you replace the dummy characters with valid cntrie" Th~ network templat~ is in.wned af1.er the "elccted network.
In the Program Editor, you cat! create new b locks, or open and edit exi,ting blocks w ithout having to change back to lh~ SlMATTC Managcr.
The add",>scs used in th~ pwgram, such as inputs and outputs or bit m"morics, are addressed in absolute or symbolic mode.
3.3.5
A ddres .• ing
Absolut e J'\etwork templates JuS\ as you store blocks in a library to reuse
them in other progmlll', you also savo network tempTat~' in order to copy th ~m "gain and again in, fur example, other blocks. To savenctwork templatcs, creale a library ~on !aining at least on" S7 pwgram and Iho So"r-ces container. You program the networks that you wanl to use
as templates quite '"normally" in (any) block. Then you replace the addresses thm are to chang~ with the dummy chara~tcr; %00 to %99 . You can also vary the netwo,k titl e and the network ~omrnem in this way. The dllmmy characters ""placing the addr"sses are p,,,semed in red because a block cann!)! be stored in thi, form , ']'00. is not sib'tlificant b~eause following saving of the network temp!ate(s), th i, block can b e rejected (dose the block without saving). After cnt<;ring the dummy ~baracters, mark th" nelWurk by cl icking on thc network number at top left before the network title . You can also combine severnl n etworks to form one tem plate; hold down the en-I key while you dick on further nctwork numbers. Now sele~t EDIT ~ CREATE NETWORK TEMPLATE. In the dialog box that th~D appears, you Can assign meaningful comm"nt< to the network and all the dummy character. . In 1he next dialog box, you a>sign a name for the n~twork template and you define lhe ,torage location (Sm
~~ dr","inl:
Absolute addressing reference" addre:;s.,s and block paramet..-n; with the addr~'s Tn and the bitlbytc address. If there arc three red question marb in the network in th ~ p la ce of addressc" and parameters, you must repla ce this character string w ith valid addresses. If there are three black poin1/;, rep1ac~'IIlem is optionaL The Program Editor che~ks that the dala types of the acs" option). Syml>ollc addressing If you want to use symboli~ names tor globa l op~>r.mds in incremental programming, these names must already be as,igned to absol ute address", in the Symbol Table. While entering the program with th~ Program Editor, you can call up the Symbol Tab le for cditing w ith OpnoNs ...", S'0-IBOL TAlIL£ and then you ~an change symbols or cm~r new symbols ,
Yon ~~tiv~IC display of the 5)'mbol addre~~e~ w ith VIEW --} D!SPU. Y WTTll ~ SYMBOLIC Rb~I1ESFO.--r,.,T!ON. The menu poim Vrliw ~ DISPLAY ViTTl! ~ SYMBOL INfORMATION provides, for each netv.'ork, a list of the symbol-toabsolute-address assignments for e ach symbol used in the network. Whi le entering the 'ymbois, you can view a list of all the 'ymbols in the symbol table with INSCI(T ~ SYl\-HlOL (0' right mouse click am! INSLRT SYMllOL) and you can then transfer one of the 'ymbob with a click of the mouse. The list i, disphLyed aUlomatically if y"u have sct Vn;.w ~ DISPLAY WITH ~ SThffiOL SELECTIOX
""
~
'>DolATIC 57 l'roi""m
](" symbol is nOi yet iru;luded in the symbol tIIl*_)OU Can scle<:t EDIT -+ SnlBOl.S. make 1111: a.tgnnICnt 10 the absolute D
y(RI can a1so edil the symbols in Regi ster "4: Add~i5 info" in the Detai ls window. Ifthe columns with Ibe symbol and the ,)"nlbol comment .are not disp layed. fetch them by chcking with !be n\lht mou~ butlon on the addrc .. table ~nd DlSPLA Y COLt.r.o.ll'S (Ol'iOFf).
If tIK- ProIl'1'P' Editor opens a compiled block. ".:.ani... OUt "decompiling" 10 the LAD or FBD .-etbod of ~pr~ntation. In do1na so. it usel 11K non-<:"il.'Cutioo·rcleVllllt program sectIOns lD .. e offline data management. in order. for anple. 10 ~prncnt symbols . con:unents and jWJ1p labels. Irlhe mrotm""on from the offline data lUllIIagement ,y$1em is mi.sina, the Pr0gram Editor uses ~ub;;titule symbols .
1'' _
3.3.6
1"lIIli- begins OIl the left JIO"er rail. You selecl the location in the nJlIj! at whieh }'O\I wlnl 10 insen an dement. then you select the program elnnents you WlInt I>
.... ;tIt
tile COIT<'Sponding function key (for example F2 for a nonnally open (NO) contaCt),
;. with 'he corresponding bUllon on the function b ar or
;. from the Program Elements CalalOIL (with il<>"5ERT -+ PROGRA.'1 EJ.L\tENTS or VI[w-+ OVEJt\'l.Ews).
You terminate a rung ....'jth. coil or. bolt . Most program elements m~t be ISSigned memory locauoD.'i (v.riable~). The eliieSI "'1)' to do this is to rtnt arrange all prognun elements. and then label them.
Con tac lS Binary arldIe-sse, ""eh as inputS are scanned u.ioa comacts . The scanned silPla l statcs at"<: combined a, ~ording to th~ ~rmngemem of Ihc comacts in a serial or paral1e11ayoUI.
E ditIng LAO Ekmeon
Prollunlmlna In lI:e ner.1 The prn]U1lm CQlUi;;ts of individllll.l LAD de~I.'I arranged in ..,ries or parallel to one aoothl"r. PTopmrnina of a current p;>1h. or
"Current flo,,';;'" through I n",,",,,,Jlly open conif the scanned binary address ha. siiDDl mte '"I"' (the contact is activated) "C"Urrent
S
"'11b "'I'P1clr.«tWy IItfICh
...... 1"."0<10< jump functioo)
--jNOTj--
SIu.dttrd b. £''0 ( .... ari
S PULSE
: ''" , Flilun ). 7
'"
0
" 1= 'CD e-
I:>c~mpl tj;
of LAD Program Elemcn"
Block bo~ .. (~ ... I"w1ctiI>It block ""U.)
D'm
.,
., in3
eo"
'"0
3_3 Propmmina; Code Block$ " . lwo~k
an
. .,
~ ...
"
~.rt.
pa,u
r.~ay
h~v ..
to ' •• Oy.
, . . ~he
- ... u ..
{p -
.....
<>f
tn. bal t , "< noy or. r ... dy
o~
u.<> .... l .
p.
i."'~ .~.
·'Mhultl·
110w~·· Ihrough a nomtolly c1os~d contoct if Ih", !/Canned binary addn:ss has si lP'ai stale ''0.. (thc eontaCI is nol aClivaled). You can al.o scan slaIUS bi lS or negale the re~ull of the Jollie operation (NOT conlaCl).
Colis Coils an: ,,-~ed to control binary addresses_ ruch as Outputs. A .imple coil Sels the binary add,....SCI when Cu.tn:nl flows in Ihe coil, and rCIICIS it when power no lonaer 110wo. There ace coils with addit ionnllBbels, such a, Sct and RC8Cl coi),. which serve a special fune__ lion. You can aIm use coils to control limeTS and counters, cal! blocb witlioul paramelers. execule j umps in the program. and so on_
Bole. rc-prcsenl LAD elements with complex functiono. STEP 7 provides ··standard boxcs·· of two difkrenl types, w,thm.1l ENIENO mech_ anism (.uch as memory functions, limer and COllmer functions. comparison boxes). and ,"'i lh ENIENO (such as MOVE, arithmelic and malh functions. data type con'·crsions). When you call code blocks (FCs. FB s. SfC. and SFBs). LAD allO rcpr-esen15 Ihc tailS as boxes wilh EJ>;IF.NO. LAD al.., provides an "CII1p1y box·· in wbicb you can CntCr Ihc desircd funClion when programming, Bo~<:lI
Layout
re~t dctions
T he LAP edilor sets ufl a network according to thc ··main rung·· principle. Th is is Ihe uppermost branch, which hegins di~tly on Ihe left power .....il and muSt terminate with a coil or 8 bo~. All LAP elemcnts can be localed in Ihi~ nmg. In parallel branchc!l wh ich do not begin On Ihe left power rail. Ihere are somelimes restrictions in the choice of program elemenls. A ddilional n:s,rielions dictate Ihal no LAD elc_ rnenl may be ·'shorl-circuited·· wilh an ··empty" parallel branch, and thaI no ··power" may flow IhrouJlh an element from right to left (a parallel branch musl be closed to the branch in which it wu O!"'ned). Any further ru lcl app lying 10 Ih .. layout of special LAD elemcnt~ Ilff discu ssed in tbe rcleva", Chapl<:T5.
'Vhen LL.ina
'" po
bo,,~
as program demenls. you
program a single box per networi<
po
arrana;c hoxcs in T brancht~ ;n branches thaI Start"t Ihe left power n,i l
po
arranl!~ boxes in series by switc hing Ihe RNO outPUI of one bo~ 10 the EN input of the follo,,""ing box
:>
SWileh boxes in parallel in b... nc~. on ,he left power rail via its eNO OUlpul
With Ihe arrangemenl of the boxes, you evaluale the signal slates oflhe ENO outputs: if you
'"
3 5lMATIC 57 Program
terminate the UNO outputs "~th a "oil, "pow~ r flows in to th~ "OJI if a ll Ihe boxe-, ha,-e all b~~n p rocessed without errors in the "a,e of ~ri .... con ncelion, or if one of the Ix,,-.. es has be..n processed without errors in the cas~ of paran~l "onnection (see also Chapter 15.4 ··U.ing th~ Binary Re~ulf').
3 .3 . 7
Editin;:; HJD
Pr<>gramminl.: in gener al T he program consists of indivi dnal progrllDl elem ent. that ar~ connected togcther via th~ b ina ry sign al fl ow to form logic operation, or ncm-'ork s_ You begin programming a lo gI c opcl"ation by sel ecting the programm ing elements on the !eEl of the logic operat ion
with the functio ll key, (e_g_ F2 for the Al'-"D function),
!>
via thc m enu
OpCra!lOn . b"xe~
A NI) B ox) or
You control bmary addrcsses ,,, eh as outputs w ith simple box~, . Simple boxes g~n ~rally have only one input and may have an additional
from thc Program TIlcmcnts Catalog (with INSERT ~ PROGRA.\! J::U::lI.Jr.-rS or
Th~re
)ah~L
YOll tcnninate a b inary logic opcr"tion in the simp le't case "'~t h an ass ign box .
,
Binary fu nction.
}\;jd ftu-",'i
fu,Id;OO
• Nega'io>·~ or""'D o.nd ,..,sul, of lli~ logic
"1" ""-'''''''
are simpk
box~,
for controll ing a binary an edg~. controlling timer and C()unt~r addre,se, . calling block> without parameters, cxecuting j umps in the program, aud so OIL addr~,s _ ~ya)ua!ing
V tEW ~ OVERVIEWS) .
:
fUll ction s
The scanning o f an addrc" Can be neg"ted so that ,can 1':>1111 "i -- can be oblained for , lat " , "0" of the address . You can abo Scan smtus bits or th e result ()f a logk operation within a logic
Sim ple
(L~ShRT ~ FBI) LA"UUA{;F ELE.'-!~_"rS ~
!>
Hin~ [ )'
You sCan the binary addresse, men as inputs and combine th~ >canned signa l stat es u,ing the binary functions AND. OR an d cx c\usi'-e OR E3Ch binary i~pul of a bo_~ also >can s tn e bi~ary address at the inp ul.
U~menn
"
.\!lost program clements must be as< igned mem ory iocation, (nriables). The eas iest way 10 do thi s is 10 first ammge all program clem en ts, th~n lahelthcrn .
Compkx boxes represent program elements with compkx funnion. ST EP 7 provides "standard boxes' in f\<.'o version.!:
~
"
•
L.
3.10 Exampk of an FBD Ketwork in "3.Dimcru;onal" Rep,"stio n
Comple" boxes
~
~,
wit hout EKIENO mechilflism (,neh as memory functions, timers an d ~ O\lntcrs, ~omparison boxes) and
example, you cannot arran ge edge evaluation. and call boxes following a T branch . Any fiorth er rules applying to the layo ut of special F"BD el emen ls are di>c,usse
""progrnm a single box pe, netw ork ;>
witb ENIENO (suc h as MOVE. arilhmetic and maTh funed
!>
arrange boxes in T branches in branches thaI stan at the left power rail
If Y
!>
arrange boxes in .eries by switching the END outpUl of one box to the EN inpUl of the following box
!>
AND or OR boxes via the END output.
FBD also l'ro~ides an "empty box" ill " h ieb you can enter the desired function "'hen pro" gramming LaJout
restri~d o n.
The FB D editor Sets " p a network from le ft to right and from tk top down. f rom 'he Idt, th~ inputS lead to the functions and the outputs exit to Ihe right ,
In Ihe case of boxes switched in >eries. you can control their process ing as a group (see also Chapter 15.4 --Using the Binary Resul1")_ You ev aluate the error mC5sag~S o f tho;.- boxe~ by combining th~ E~O oulpUlS: ANDing of the ENO outpUls is fulfilled if all boxes have been proc essed w ithou t error, and ORing of the ENO output$ is fulfilled if one of the boxes has been proee".d without error,
A logic opcratio ~ always bas a ''1erminating funct ion" _In il~ ,impl e,! fonn, this is an assignm ent of Ihe result of the logie operation 10 a binary address,
3.4
With the he lp ofa T branch of a l(}gic o pera tion, you can program funher '"'l cnninating functio~s- ' for a logic operation ("multip le outp,,"'), Following a T bran ch howeve-t, Ihc selection of programmab le el ~ments is ,estricted, for
Chapt"'" 2 .5 "Creating the S7 Program" gives an introducl ion to progT"4m creation and the uS" of the program edi tor. Data b locks are progmmm ed in the same way in LAD and FBD, .'
Programming Data B loc ks
m
3 SI).IATIC S7 Prugnun 3.4.1
CTnlTing Data Blocks
t>
You be!,;in block programming by openiD& • block. either with a double-click on the block in the project window Qf thc SL\tATIC Manager orb)' "'Iceting FILl:! ...... OPEN in the e,wor, Iftbe block doe s not yet exist , create it as foI1Q"~: t>
t>
In the SIMATIC Manager: ,elec t the obje.:t BloeM in th~ lefl-band ponion oftbe proje.:t windvw and crcat~ a new d~ta block with IN snRT - t S7 BLOC,,- ...... DATA BLOCK. YOIl lICe the properties window of the block, SpecifY the number and Typt o f Ihe
··Dala block referencing a user-
I>
·'Data block referenc ing a functi()T1 bl""k·' or ··In
Cf(;lIti011 as an instance dala block; hcre, Ih~ data " ruct u'~ been presIIIlt io the block: ton miner. The S3me applies 10 !heereat;on ofa data block" ilh ""signcd function block.
3.4.3
Hlock WIndows and Vie""
You Cln till out the h~adcr of:> block as you ereIte it or you can add the block propcnk! .t II laler point. You proJOllUIllater addition§ [0 [he block header in the editor by selecting FILE ... PROPIlRTTfS while the block is opI:D.
When opeoing a dSla block whon lIrueture is baenien! parameterization (...., Ch.aplcr 2.1.8 ··~onj:oring and "'lodif~"U1g Data Addf(;s~s·,. The datH ~ie"'s are d~riboo b<:low.
3.4.2
The propam editor pmvide:; t"" vic,," for programming (cresling) dMa blocks:
Types of Dat a BI""k.
Whcn crcati ng a new data block . you ar ~ requested to defme ito; type, \Vhcn crcat,,,!! using lhc 5lMATIC Manager. you Set the type in the ,eleclion box of Ihe propc"rues window; when creating wilh the program editor. by cU<;king one o f lhe options offered in [he '':'lew dHta blocL " window. A ditre~nltalion i. made hc:tv.ecn tllrH typeS of data block depeoding on their erellion and appli«tion; I>
u.
MDatll block·· Or ··Sha~d OS·' Creation global data block.; ~·ou decla~ the data addre",es wheo programminij: thc dHtn block in this CH.C
'"
;;. Tbe d eclaration view is used 10 define the llats structure for global daUt bl<.><;n, as "c 11 ~_~ Ihc de fault values. eo You Can handle the online v.luc! in Ihe data >k
".
Eacb ' -.e" · presents a table conlPining the abso1u1~ data add.... se. in sequence. tM n8Jt>C' and clara 1)-ptS. the initial values aDd corruncnts (Fig_ ~ 3.11). The data >->cw eODtatnS an additional column with the actual 'aluc. If you oprn a data block from Ihe omine data management, you arc provided with Ih~ oftline " '11"10,,, "'nh "hieh you cao edit Ihe d~IH in the pmgrammin g device. !fyou open a data block
3.4 Programming Data Bloch
F j~U T~
3.11 Eumplc or on Orene<:! [)"" 1310";' (Dednration Vie"-")
which i. present in the CPU "s u, ermemory. th~ editor di,p l~y" the online window wi th whi ch you can edit the data val ues on the CPU.
Offlin e w indow You I,"C the dec laration view for input;; w ith global data b locks You dcdare th~ data addr~sses in th is view; you definc lh~ s~"uencc of data add[\;\S~s. assign a na me and data type to each data address . and Can "dditional1y em er a conuuem. Each data add .. e
"=. The data "dtlrc>se, "nd the d~fauh values are already dcfincd for data blocks which [\f~ derived from a user dam type or from a fundion hlock. They are obtained from the declaration
of the user J"t.~ type or from the th~ fundion block.
d~cI "r~tion
of
The data view additi onally "hows th e ""tual value colwnn. The default values from the initi al vo lue column arc entcred as standard in this co lumn . In the data "jew. YO Ll can enter a d ift" ren! in itial value for the load m emory and thus an act l!ai value for the ",'ork memory (F igure
3.12). The possibility wh ich exim for assigning indi vidual default value. to ea ch data block is parti cularl y im portant for the data b locks derived fmm a Ll..ier data typ<: or from a function b lock. t'or example, if you generatc severnl instance data blo<.:ks o f a function block, all dala b locks have th~ defau lt value sct in the function b lock . In the data view, you can m>w iT1 dividllally as sign other values to various dam addresses for each in.tan ce .
115
3 SIMATIC S7 Program
view
In the offline win<1ow, y ou roit the ,"'''' in ,~c ofllin.< data ~lOna~
In Iho vtiliJ,. "ind<>,". Y"~ monitor the da", in
Hgur e 3.12 Data SLo!"a!F wilh Incremental PrognlIrnniIl8
Online w indow You usually usc the on line window to view the actual dam valu~s ;1) \he Ll'er m emory. H(lw_ ever, you C"n also u,e ;t to generate d ata hloch. The initial value column;n the dec laration ,~ew show. \b e init; a l va lu e from the oftlin e data m anagement or thc ini\ia l ,'alue from the load memory if tb~ omine project a'.,oc iated with the CPU program is n ot av ailable _ The acnml value column ;n the dma view d is plays the a~tual value from thc work memory. W ith E VIl' ---> I N TTIAUZE DATA BLOCK you requ~s t the ~d Ltor to re place a ll actual value, hy the in itial values agai n.
defau lt valu e, and th e oaluc in the ''':tual val ue colunm a , the initi al value inlo the omine data man"g~m~nt.
Kote that the comple te inform "tion ~o n cenl i ng data addresses, such as e.s- lh~ name, is only p resent in the amine data management. 11 i" nx:ommendah lc to also write the d ata bloch g~ llerated in the CPU'. user memory into th~ offline data lIllIllagem ent so th aI data consi, tc ncy is rcl"incd (Chapter 2 .6 .5 "Block Handling" u nde r "D~ta block> offiille/olllin~").
'''ill
Wh<.-,,! wri \i ng hack with PLC ---> DOWNLOAD. you write the ,"a lu~ in the i1~tui11 ,"i11ue column into the work mem ory_ You arc there fore able 10 use the progmmrning device 10 inilu~ncc \he values of data addres,es during rrogram eXecution. ThO' yaluc in th e ;n itial v alue column is rej ected. Wh~n w rilin g hack with FlL_ t: ---> SAYE . you write the value in the initia l value ~oJumn "'" the
'"
3.5
Variables, Constants and
Data Types 3.5.1
Generul R~mal"l<.~ Con c<'rnin g Variab les
A ,' ariable i, a value with a >pc,:ili e format (Figure 3.13). Simple variable. c o ns ist of aa address (such as input 5 .2) and a data typ;; (su~ h as BOOL for a bi nary value) . The addres" in
3 .5 Variable., Con.."nt. and Dam Types (Urn, comprise, an addtess identitier (wch as J for input) and an ahsolute stomgc location (such '" 5.2 for byt~ 5, bit 2). You Can also ref_ ~n;nce an addre" or a variables ymbolically by a«igning the address a namc (a symbol) in th~ ,ymbo l table.
compon~nt ,, ~Iues
of an array consisting of 30 11'T into the accumulator and furth~r proccss
il). Constants a~ used to pres et variable> to a fIxed value . Th ~ constant is given " spe~ifi~ prefIx depcnding On the data type .
A hi t of data type BOOL is refe rred to a s a binary add,.".,., (or hinll'Y operand). Ad d,..."es comprising one. two or four hy:cs "If vari ~bJ e~ with th~ relevan1 dala type, are called
opcr"nd,' Variablcs. whkh you decl are within a b lock. are to a. (block-) loca l variables _ These include the block paramel<:rs. the static and temp orary loc"1 dam . even the dara addresses in global dara b locks . When th ese var i abl e~ are of an e lementary data typc, they cau also be a cces.ed as operan d., (for instane~ s tat i~ lo~a1 data as UJ op~rands, temporary local data as L opcratlds. and data in g loba l da:a b locks as DB operands). r~ferrcd
Local variahl~<, h owcv~r, ~an "Iso ~ ot complex data typ<> (such as stnlC111res or arrays). Variables wit~ th~,e data type, reqllire m On! than 32 b its . s(' thal \h~y can no longer, for example, be loaded int0 the accumula tor. And for t h~ ,arne reason, they cannot h(: addrC"S,ed with "normal" ' STL
or
If variables complex data type contain com· pon,,'ms of e lementary data type, the
01"".
A v>0a..u;, """sis" ""d",u and ,1>8 da,~ 'J'P"Hi•• J~.><>d 'y""'xJ;Cd#y,
Va_ia ble
I
3 .5.2
Address;n!,: Va riables
Wh~n
ad dressing variables, you may choo.e betwcen absolmc "ddr~ssing and ,yntbolic addres sing [>
[>
Abso lute addre" ing uses numcri~al addresses beginning with zero for c,,,,h addre,s area. Symbolic addre,sing u.;;es alphanumeric natllCS, which you yourself dcfmc in the symbo l table for gtobal addr~.'es or in the declaration section for block-loe,,1 addr~sses .
Ab so lute addressin!;: of variables Variable. of ckm~'lItary dat a type can be referenc ed by absolnte addresses_ TI,e ab sol ute at!dr~ ss of an input or output is computed from Ihe module Slart addre ss, which you ,ct or had set in the configu",tion table and the type o f s ignal ~onncction OIl \k module_A d istinction is m"de bC lwccn bi nary ~ignal~ and ana log signal< Bina ry I'ign'l/S
A binary signal conta ins one b it of in formal ion. Example, of binary signals are the input signa ls fro m limit ~witchc~, momentary_contacl switches and 'he like whieh lead 10 digital input modules. and output ,ignal. which control lamp', contactors , and the like v ia digi1aloutput modu l e~_
Ana/"K .l'iKna/s
Add ress .. 081" 1yP'"
Address klenHfier
Fl~ ur.
..
Memof")' location
3.t3 Structure of a VMl.b J~
An analog signa l contains 16 bils of inionnalion . An analog s ignal corresponds to a "~han. ncl", which is mapP"d in th~ con!rol ler as a word (2 by tes) (sec below). Analog input signals (such a< voltages from resi,t,once 1hcrmom~"1~Tll) arc carried to analog input moo uJe<, d igi tized, ant! lllad ~ available to (he controller as 16 information bits. Conversely. 16 bit~ of
J S(/>'tAflC 57 Program
mfonnation can control an indicalOr via an analog output module, where the infomlaaou is cun ,'~ned into an analog value (such as a cur_ rent), T he information width of a signal also c~ sponds to the infonnation width of the "ariabl~ in whieh the signal is slOred and processed . The infonnal ion width ~nd the inlcrprclation (lflb~ informat ion (fo r ;n;;tanc~ the positionsl weight), taken tog~t her. produce the data typo of the variable, Binary signals an: store d in variable, "f data type BOOL analog signals in vaTiable, of data type L'\T. The only determining factor fo' the addres.>ing of variables i~ the information w idth. In STEP 7, th~-re are four w idth" which can be acce".d wilh absolute addressing' t>
1 bit
t>
8 bit,
Data type BOOL Data type BYTE or anmh~r dala type with I; b its
t>
t>
16bit s
DatatYP<'WORDoranothndata
32 bits
VAriables of data type WORD com;;"t of two bytes (a word). They ha>e as absolute addre,s Ihe address idemifl~r and th~ number of the low-order byte of th~ word containing the variabl e, The address idcntiflcr "' s\1pplemented by a \\', Example,' IW.t
Input word no . 4 : cOnla;"'; bytes 4 and 5
QW 20 Oulpllt word no . 20; contains byle, 20 and 21 Variables uf <.!ata type DWORD consi" offo ur b'1C~ (a doubkword). They have as ahsolute address the ~dd,"ss id~ntifior and Ih e nw nbeI of the lo\\-orJer byte o f the word containing lh~ variab le. Th e address identif,er is S\1pplem~nt.d by a D. Examples:
Data type DWORD Or another dala Iype "ith 32 bil'
QD
Output doubt.word nO. 24: contain, byle' no . 24, 25, 26 and 27
Q 16.4
Output b it no. 4 in byte no. 16
Variabl e, of data type BYTE ha"e as abwlUlc address the address identifier and tt.c number of
OW, 26
QW24 ,
"I
os
•.. 1 07 ." .. ,07 .. 25 OS26 CB27
I
2~
Addr.,ses for the data area include Ihe data b lo~k, Examples :
DB lODBX 2.0 Data bit 2,0 in dnta block DB 10 DB II.DBB 14 D~la byle \ 4 in data bloc\:: DB 11 DB 20 .DBW 20 Data word 20 in dala block DB 20 DB n.DBD 10 Dam doubleword 10 in data block DB 22 Addi'ional in fonnati'", on addressing ' he data area call be fOllnd in ChapIe. 18.2.2 "Acces>ing
QD, 2"
I
QW2S
F11:IlN 3.1.t Byte Co ntent! in Woru.; and Double" ",,
''"
Variable, of data typo BOOL are rdcrenccd , ·ia an address identifier, a hyte n ",mber, and ~ scp=ted by a dedtnal point - a bit numb ....... Num bering of the byte s begms at zero fo r nch addre,s area, lbe upper limil is CPU-specific. The bils ar<; numbered from I) to 1. Examples:
,
the byte containinR the vari able . n ,e addre" iMmifier is supplememed by" B, EX3mplcs;
0= Openmds" Symbolic addrc"in g of variables SymooJic addressing uscs a name (called a symbol) in place o f an absolute address, You you,selr choose mi.> name. Sueh a name millt begin with a letter aud may comprise up to 24
3. ~
characters. A key\vord is nol permissible as " symhoL There is no difference between u pp"r-case and 10wCT-ca,~ leners when <.--nlering a symbol. During the output, Ihe ~ditor applics thc notation defincd d uring declaration oflhc sYInbol. The nam~, Or symbol, must b e ~110C31ed to an absolute addr~s,. A. di st inction " made betwecn glo bal
Variables, Con Slan ts and Data Types
leading '·if'·. Whcn tb c Edito r cannot distinguish a local symbol from an address, you In ..... t p rece,j(; the symbol wilh a .. #" eharncte r during inpnL Local symbols are available onl y in the pro--gramrning device database (in thc omin e con_ tainer Blocks). Iflhis infonnation is missing on dccmnp ilatin", the Edit"r in~crt.~ a s"bslimtc symbol. Udnll symhol names
G lobal symbo!. You may assi!{T\ names in the symbol tabl e to Ihe fo llowing objccts: r>
])a13 b locks and codc b lo<:ks
r>
Inputs. outputs, peripheral periph<.-"TaJ OUlp"ts
r>
Memory bi ls, timet> ',nd eo"mer.;
r>
User data type5
r>
Variable tables
mputs
and
A g looaJ symbol may also include spaces . special characters and counIty_sp~citk charaelers such a" thc umja,,(. Exceptions to this rule are the characters OOh~-' and Ft'ho' and th~ quotation mark ("). \vllen using symbols contaiJ,ing special ch aractt-rs, you mu..
You can us c g lobal symbols throughout the p rogram; each such "ymbo l m1.lS l be uniq ue within a program , EditinK imponing and nportinB of glohal symbols ar~ d~scrib~d in Chapter 2 .5 .2 ··Symbol Table", Btock_local symbols T hc names tbr the local da'a a rc spec ified in the dec laration seelion of th e relevant b lock. These names m ay contain only le n ers, digi's and the unde rline character (no umlauts'). Local "ymbols are valid only within a block. The 8ame symbol (Ihe 83me variab le name) may b e used in " differ.-nt context in another bl ock. The Edil-Or shows local symbols with a
If you us~ symbolic n ames while pwgramming w ith th~ inc r~menta l Editor. th cy m ll.t have already been alloca ted t o absolute addre.se " YOli also have thc option of cnleriag new symbolic names in the symbol18ble duri ng proj,r ram input , You <:
In the case of arrays. the indivi du al c omponents ar~ a<:cessed via the array name and a 8ubscri pt. for example MS ERI ES[1J for Ihe fi rst compone nt. In L A D and F13 D . the index is a constant INT valuc , Itl : ro r insrance FRAM.E.H EADER .CNUM. Component.< of ",er data lypeS a..., address~d exactly like structures J)atlllldd~ess~s
Symbolic addre.sing of data uscs complete ad dre s>ing including the dat;, bk><; k. Example: the data b lm;k with th~ symbolic address /l,-fVALUES com>1ins the variahles MYALUF 1, YiVALUE2 and M TI ME. These variables can b e a,Wr~ssed a, fo llows: "MVALUE5" . ' 1 \ , = 1"NVALUES".MVAInE 2 " MVAL1.rES" .'1T!Y.E Pl~ asc refcr to Ch apter I ~,1.2 "Accessing D ata Opcrnnds·· for further in formation on addressing of data.
'"
3 SIMATIC S7 Program Table 3.4 Divi,ion oftht 0... T)Ipc.
~
~
J.!.J
(n bits)
O,·tni.w o rD llal)'ptl
You ~an find example. of the d~d"nltion and ust of vanabks of an data \'I'\~$ in I~ hbrn.ri"", "LAO_Book" and " FRO Sook" undenhe pro-
Da\a \~ ,\i'llU\a\.e me cn:!.!amris\ics of data ell5enlial1y the repr~>;cnlalion orthe COntenl, of
grDm "Data Types" program that yon can download from Ih<: pub lisher's Website (
a variable. and the permissible rangco. STEP 7 provide!! predefined dala types. which you can c<>",bin~ in.o u_= dIt", !ype>O.
The da\a ')"\'ItS lIt avai\ab\t on a ¥,\oba\ basis
a word or a doubleword. Tlble 3.6 mow,; the elementary data type. _For m~IlY data type,. there are tWO con,(8nt r~pr. sentutions tnal you can use equally (e.g. Tuv\ Elf or Til). The lable contains \1M: minimum value for a dalll type in the upper line and the maximum value in Ih~ lower hne.
lj5Cf
O« llra tioD of eleme ntary da,a types
Table 3.4 ~hOW5 the pro~rties of Ih.,. d>.ta Iype das5<'s. Table 3.5 E.uOlplcs of O•.::l.nuion >ad Initial V.luo , [
I
-
Dalal»pn
f...u.~
Depending on stru~IU", and application. Ibe data types with STEP 7 are classified as foilows:
I11o---....."'['<~tttenmry
EI~mtntary
""
Table 3.~ shows some elUlmplcs urthe declara(ion of v8riable. of elementary dala ~s.
DI" I ~JO.(JI-O 1 DATf-'1'2168- 12-3 1 TIME 01' DAY
(32 bits)
Time of day
TODJoOO:OO :OO 1L\-lE OF DAY~23 : 5~:59.999
1) "Lit" may be "mtlled ,[the numocc 1> outsld~ tho L"l number rang. I)
for value r.mg~
>C'C
text
3 SIMATIC S7 Program
Na"", is the identifier for a block-local variable (liT' to 24 chara~t~r', aJphanumcri~ and underscore only). YO ll em er the associated data n'"," in the Type column. With the cxception orthe temporary local data and h lock parnmeten o f functions. you ~an assign a t> initial vallie to the v"riable,. Use th~ ' yntax suitable for the data type for this PUTpose. Commen fs are optional.
BOOL, BYTE, WORD, DWORIl, CHAR A variab le of data lype BOOr. ""prc>cDI, a b it valuc (for cxample input I I.O). Variab les with data types BYTE , WORD and DWORD are b it .trings comprising 8, 16 and 32 bit,. respe~ lively. The individual bilS are not cvaluated.
CHAR A , -arinble wnh data Iype CHAR (character)
r .. seryes one byte. Data typ.- CHAR repuseuts
a 5ingk ehameter in Asc n format. Example: ""N·.
Yon can us .. any printable cbaractcr in apo,troph .. , . Some spec ial characters rcquireuse or the notat ion ~hown in Tabl .. 3.7. Example : 'SS' represcnl. a dollar 'ign in ASCI! code. Tabl. 3.7 Sp
H~
n...,ription
",
4 2 """
Doll.r sign Apostrophe
"00
L in~
Sl or $1
17h....,.
fe«l {lf)
Special fon n s of the,e data types are the Bel) numbers and the count ~s l1
SP or Sp
BCV n~mlx,r,'
The (l. IOVE function aUows you to us~ lWO or tom ASCli characters enclosed in apostrophes ~, " sp~'Ciai form of data type Cl lA.R for writin;:: AScn charaCl<:rs in a variable.
BC!) numb<:rs hs'-e no ,pecial identifier. Sim ply enter a BCD number "ith the data typ .. 16# (hexadecimal) and use only digit> 0 to 9.
BCD number' occu r in coded processing of time value, and counts and in conjunction wi th conversion functions . D ata tyJ>C S5TTM1, " i, ">cd to specify a time value for 'tarring a timer (.ec below), data type 1611 or C# for ,pe~ifying a count vallie. A C # count value is a BCD nuInber between 000 and ')')') . wh .. rehy the sign is always O. As a rule , lICD numbers have no sign. In conju nction with the conversion functions. the 'ign of a BCD number is stored in the leflmo>! (h ighe't) decade, so that there is on~ lcss decade for the number. Wilen a BCD numhcr h in a 16-bil wsignment appli .. s for a 32-bjt word. The availab le value range is 0 to ± 999 fo r a 16bit BCD number and 0 to '" 9 999 999 for a 32bit number.
OC• •
No,.. page (rt)
SII. or Sr
mJ~.
Camaie re"'m (LK)
S'T '" $t
09."
'hb,,]alo[
T"T
A variable w ith data type INT io; ,tored as an iut • .'!e, (16-b il tixed-point "umb.. r). Data type L"'T ba.s uo special identifier. A ,"sriabl .. with data t ype Th'T T"<:"""'-'" one word. The , ignal ,tate, of bi ts 0 to 14 r ep res ~"l the digit p",itioru; of the number; the signal , w e of h it 15 represents lhe si),,'Il (S) . Signal state ""0" mean, that thc numlx:r is po;;itive . sig nal state ·' 1"" that il is negati' e, A ne gative num· ber i, repre,ell1ed as two', compl.. ment. The permissible number range is
from - 32 767 (7FIT"",) to -31 768 (8000ocJ. DL"T A va riable v.ith data type DINT is stored a< an int ..",~r (32 -b it fixed_point number) , An int eger is stored as a DL"I T variable wh .. n it .. xceed, 32 767 of falls b«Jow 32 761> or when the number i, pr~c ed.-d by type id .. ntificr L# .
3.5 Variables, Constants an,1 Data Ty)'('s
.
BCD number, 3
Data typ" CHAR
.
.".
1
dee~d •
•
0 \
, ASCI! Cod.
S;gl1
BCD num""r, 7 deeadu Byte m
28127
Bytem+2
Byte m+1
24 123
,
"
Bytn m+3
,
20 [ HI
Sign
15 14 ...
Om type INT
D~'" typ"
OINT
3130 ... 1S 1 D~UI
2302
"'.
••• 11> 15 _
d ;;
..2'"12'" ..
... 2'2' 1'1 :
Iyp" REAL
3130 .
... 0 '"
... 2322
,
• Data type S5TIME
15 14
D~"'ty""DATE
1514 .
... 0
,, 'n !)
'I','"c,'".',''''.-,------------,~·;'-""~~I ,
3130...
I5I2302",...
,
':: '
Data type TIME .16 15
'~"I~", .'
"
... 6 " " .
Data type TIME_Of _DAY
3130
5
... 1615 ...
, 0
Sign
m
3 SIMAnc S1 ProJ!I3:n
A variable with da.~ type DiNT re,erYCS one doublewoml. Th.o: signal e digit posi.ioru; ofrl>e number. ~ sign is s.o;n-ed in bi t 31. Bit 31 is ''0'' for a POSI.ive and "1" for a n.. gati ..... nnmOO. NegallH numbers aN:> stored as two', complement. The number 11l"],:c il from .,.2 147483647 (7FfF t 'FFF box ) to -214 7 483648 (8000
~J.
REA L A variable ofdaU-type REAL represents. fra~
lion. and ;5 ~w..ed liS an-bit flrnning-poim numb<."T. An i ... tllC1" 1~ ,tore
In exponc:rJ! ",pre§t:ntalioJ!, you can pr«cde tbe or " E" with an imeger number or frlle.ion ",ilh Seven relevant digil$ and a sign. The diglls that follow the "e" or "F' reprcsem the exp<>nent to b .. sc 10. STEP 7 handle. the conversion orthe REAL variabl.. into the internal representati on of a floating_point nnm""'. ~e"
REAL variables are divid ed ;nt" numbers. which can be represented witb comple.e aCeurney (''nonnah1.w·· noating-pointnumbers) and thos.e witb limited accuracy ("!lenOT\lllilind" floaTing-po.ot numbers). The ,..lac range ofa nonnalizcd fl""tina·poin. number lies between, 3.402 823 X 10-l8. 0 - 1.1 15494 X lO-l8
'0'
.. 1.4·01 198 X I~~ to "'!.l73 494 X ]()_Ja
n 'e S 7-300 CPLis Cannol ca!cula.e wi.h denarllIali:tffl float ing_point numben. Th e bit pnttern of a denOlmali zed numlxr is in1el"Jlll'tcd ~~ a 1.ero.lfa rcsuh falls w;thin .his ranilc, it is rep· resented a. zero. and ,tatu. bit. OV Bnd OS arc ~et (l\crflow). A \"ariahle of data type REAL consists .nler_ nallyoftrnee components. namely the s'iln. tbe S-bit c~poncru to base 2 0Uld the 23-bit man· tina. The sign ma~ assume the '"lItue -0.' (posili,e) 01" •• , •• (oe!!a.i,·e). Beron" the exponen. i~ stored. I constant value (bias. -I 27) is added 10 it SO that it sbows a "~Iue ... nse of from 0 10 255. Tbe mantissa repre"""IS .he fnoctional portion of tl>.- number. The inteaer ponion or the manti,sa i, ,,01 sa' cd. as it is either always I (in the ca~ ofnonna lized floating-point numbers) o. alway' 0 (in the ea,e of d~'I1
SHL\l£ A \"ariablewith dara I)'pt: S5TIME is used in the bB~IC iani'Ja!!C"S STL, LAD and FBD to ~et tbe Slil.1ATIC timers. It n::ser.o:.I one l6-bit word with I + ] decades. The lime i, spcciJied in bours. minuteii. sccond.$
and milliseconds. STEP 7 handles convc ... ion
'" i
A dc-normalized floating-pomt number may be in the followin!! range: LIn 494 x 10- 31 to -1.401 298 )( 10"'"
1.17S 494 X 10 U to -30402 823 X 10-;8
in to imernal repre5enta.ion. Internal
Tabl .. 3.M Ronge Limi" of a Floatini'Poilll Numboc r Sign
,= II'"'pli"" dcDomIahzed floatm&-poinl number 1\'pri'" nonnati2ed fioaUJIa-point Dumber infinite
1\Ot . ,-..ljd floa,ina-poinl IIUml=
1'q)1l'$C11-
3.5 Variables. Constants and Data Type,
talion is a, BCD numher in th e rang~ ()()() to 999 . Th .. tim e interval can a>sum.. the follow ing v"lu~s; 10 m. (OOO() ), 100 ms (0001), I < (0010). and 10 s (0011 ) . The duration is the product oftim~ interval and time value. Examples;
a decima l point, may be omitted
S5TIMEII'500ms S5T#2h46m 30.
3.5.5
(- 005 0t,eJ (- 3999 h<.J
DATE A va,iable with data (ypc DATE is stored in a word as an un< igned d_po int n um~r. The ~ont~'T1t' of th .. variabl.. correspond to tae num ber of days since 0 I .0 1 ,1990 . I ts repres~lHnti o n shows the year, month and day, separated from on~ another by a hyphen. Example"
t"". .
DATE#1990-D 1_0 1 0 #2168-12 -31
(- OODOj,e, ) ( = FF62 tcx)
Tll\lE
A variable wilh dala type TIME reserves on~ doublewo rd, Its representalion contain, the ;tlfommtion for day s (d) , hO UTS (b), min u~es (m) , ,eeond, «) and mi ll i, cc o'M d;; (ms). wherehy individual items of this in fonnmion may be omiucd . Th e contents o f the "ariab le are interpreted in mi llisecond. (ms) and .,ore ) TlM Ei/Om < (- ()()()O _ OOOO~e,J T#---24d20h 31 m23s64gms (- 8()(I(:U )()o)I\oxl A "decimal r~'Pr~,untat ion" is also possible for
TIME. e.g. T IMEII2.25h or Tlt2,25h. bM mpies: TlME#O ,Oh
STEP 7 de fines the following Four complex da!a type s ' t>
DATE
A~ D
TlM r
Da! .. and lim e (BCD-coded)
t>
STRING Lnaraeter string with up to 254
Chaf3Cl~TS
> ARRAY A rray variab le (combination of variables of the sam e type) t>
STRUC T Stnleture variable (~ombit1atioll of variables of d i{ferct1l types)
Tk data type, arc pre-deli ned, with me length o f the data type STRTKG (characwr stting) and the combination and size of (he data tyre' A RR.".Y and STRUCT (s!r.uolUre) being dd" w(i r.y (he US~T, You can declare variables of complex dma types only in global dam b tock •. in instan~e data b locks, a s temporary local data or as b lod< p a r amet ~r s
Vari ahle, of comp lex data types ~an only be applied at b lock parameters a. complet.. variable., There are TEC functions for proce"ing variah les of data types DT and STRTN(,~ e ,g. extract ion o f the d"tc an d conversion to the DATE rcprcscnUl ~ion or comhining two charactcr strin g' to one variab le. Thes~ me functions are load able standard FC b locks that you ca" find in the Stan dard Ubmry under the lEe Hmclio" Blocks program.
TarE_O t' _DAY
A variable of data type TIME_OF_DAY rCSC1"\'es one doubluword . It contains thu n~lln ber of milli s~~ond,; since th " d ay bcg,m (O:OD o 'clock) in the form of an uns igned fixcd_poim Ilumbcr. I!s r.... pre'emation contai ns the information for hours, m inu tes and s econds, "~'Pa rated by a eol0l1 The m illiseconds, which follow the second, and a",
DATE_ A;\'T) _ lTME The data typc DATF._ AND_TIME represents a tim e cons isting of the date and the time of day. Yon can also us e the abbrn ia tion DT in place o f DATE ANn TTM'E. The individua l componems of a DT variable are A Se n coded (Figure), 16).
125
3 SIMATlC S7
Tabl~ 3 .~
PrO~'Tam
lOxampl« or the Dcda"'tion of DT \ 'mable< ~n d STRL'IG Va".hk,
STRll'OG The dat. type STR Ih"G represents a character ~haracten;. Yo" .pecify the maximum p<.:rmissib lc numlx.'T of character< in square bmckcts foHo"ing the keyword STRING
.tring consisting of up to 25 4
Th ig speci fication ~"n abo be omitte<:l; the Edi(or th~n uses" kngm of 2$4 byICs. In (he ca:;c of function , FCs. th ~ Ed itor doe, not permit specification of the !cnh'lh or it demand:; me standard length of 254. 1\ variabk of d"T~ type S TRI NG oc~upks I\l/() byt~s more of memory than th~ d,.,darcd maximum I~ngtb.. Prc-ass;gnm~nt i, ~aniod OUt wilh ASCllcoded characters be(ween single invcflcd com_ mas or w im a prdixed dollar , ign in th~ ca<~ of cenain characters (see data typ~ CHAR)
If th e initial Of pre-assig ned value is ,hortCT than the declar.u maxinmm lenglh . (he remaining charactCT localion, life not reserved. \Vhen a ,'ariahl~ of data type STRING lS post- proonly the currently re.,erved chilra~t~ r locations are taken into consid~ration. It i, abo ~~>sed.
pos~i blc
w ddin~ an ··empty string"· a~ the in i_
tial value . Figure 3. t 6 show, the stntCl
Data type ARR."..Y r~pres ~nt' an array or fidd compn$;ng a ftJ
,p~ cify
the range offield indices in , quare following the data typ" ARRAY. The ,·alu c (lU 1he le n must be less than Of
brack~l' in; (i~!
a.too form8t STRING
o.ta format DT Yur
o bi$ 99
B),".e
Byte n+1
Month
1 bis 12
8 y"" n+1
AC".llall.. ""th
Byte ..,.2
0"
1 bi$31
By:e n+2
tstcltua01e-
Hc ur
O bis 23
Byte n+3
2r..d ::I>ar;ocer
Minute
Ob is 59
Byte ...
..
Second
Obis 59
Byte n.m+1
m·rn <;haracte r
"'
Obis 999
8;'('~
..
n
Byte n+3
I"e,~~
n+4
Byte 0+5
·~yte n+6 j3YteI1+7
~
I Wee kday
W""k<]ay _ from 1 - Sunday to 7 - S"tl",hy
Flgu rc 3.16 Structure of . DT and a STR NG \"aria":"
equal 10 the final value on the righl. BOlh indiC<;~ are TNT numbers in the NI"lIc - 32.7i>R to +32.767. A field can lIa'·., up !O 6 dimensions .,ach of " ,IIO!!e I imi1S are separated by D= 1 .
Th., datD Iype of the individual field componems i. located in the line under the da,a l}-peARRAY. All dDta Iype. c~CCpt ARRAY are per· mi .• sible: it can also be a use r data Iype,
PNt_as,01 he ~atcr than !he number of fie ld COmpoD~nlS. The p,.., .... ssignment values are each Separaled by a eomma. Multiple pre-assignme!l1 with Ihe SlIme vlIlue, is specified wilhin round brockelS w;lh a preceding rcp<: lilion faCtOf.
ter ir Ihc bloc k parameter is or Ihe ... me data I)'pe: as the components.
If lhe indi ~id'-'3.1 ficld compom:lIls ..,.., of elemenlary data types. you can process them ""~th "norma\"' LAD or fBD functions. A field componenl is IIcresscd will> lhe field name ami an index in square bracke ls. The ind ~l( is a tiJ
Mlllrl-dim"n.
or the variables
An ARRAY variable always ix"n! at a word boundary. that is. at a bytc ",ill> an e veo address. ARRAY ,·ariabl"" oceup)' the mcmO
Application
Component. of data t)'pe nOOL hellin in lhe leaST silP'i lkanl hil; cOmponenlll ...r data type BYTE and CHAR begin in Ih~ right·h.,nd byte. Th~ individual componenlS are lisled in order.
You can appl)' a field as a complele variable al b lock panmCICN of data type ARRAY with Il>e same Structure or al a block panuneu,r of data Iype A.."-"Y. F O'f example. you can copy lh
In multi-dimcnsional fields. Ihc compotlcnlS ..,.., slored line_wise (dimerulion·wise) statting "lib Ihe first dimension. With btl IUld byte componcnll. a new dimens;,," always 5t;u"\S in the neXT byte. and "ilh componenls of other data type •• new dimen.ion alwlI)'$ starts in Ihe nexl word (;n lh~ nex, even byt~),
3 SIMATlC $7 Pn>gnun Ta bl .. J.1I hJ.ampl .. ofD""lariul! . Name MotC",u
""
Off
0.1.)'
maxSpu
T,~
~
1,,111. 1V.lut
'''U~
"''''' '00'
SSTI\IJ: ,,~
END_ST RUCT
FALSE
TI
"'00
STR UCT Th~ d~ta ~
STRUCT represeD~' data SUUC· lun: oomiSling of II. fixed number of components Ihal can each be ofa diff=1 dna I)~. You specity the individual structure ~ompo "ents aDd their cia", 1)'}lC5 under the ]inc with lhe variable name and the key"ord STRUCT. All .lat. typel' can be used including othet siruciures,
At the declaration stage, you Can ~-l5sign values 10 the individual structure componrnl$ (nol.., a blo<;k paramcterm a function. as an to (lut parameter in II funnion blOf;k or (IS a temporary variable). The data type. of the pre-assign. ment "alues must match the cia ... types of the components.
C,mmnl Simple ,lnI<:tun: ,~able with 4 componmb Vto:iAbk :-ll>ICont.Dn oftyl'< BOOL Van.ble Mo,cont.Dff of typ: BOOL Van.ble )o.lo.co ~'- Delay of type SSnM E V"".bk :\lo!Cont_ m,,~SP<'e
$m
A STRUCT ,'mabIe alwlYS bc:iW II • word boundary. thaI is. at a byte with an eH1' addre:Js; following thi;" the indi"idlUll components are ~8!<:
Componcrm of data tylX BOOL bellin in Ihe least signifkam bit; components of data type BYTE and CHAR begin in the right-hand byte Components of other data t)lpl:s be:gm 8t a word boundary. A nested structure is a strotture a, a component ofanother stroclUn'. A nesting depth of up to 6 ,tructures is possib le. All componenlS can be: accessed indi'~dually with "normal" LAD or fBD functions pr",~ded tbey .re of elementary data type_ The individual names arc eac:h ,cpa-
nlted by • dOL
3. 5.6
Application You can apply a comple,e variable at block parameters ofd.ta type STRUCTwith the same Sln lctull' or 8t a block parameter of data Iype ANY. For example, you can copy the contents ofa STR Ucr variable with the syst ~m function SFC 20 RLKMOY. Yo" can a lso speetly an indIVidual smlCture component at a block parameter if the block parameter is of the nme data Iype., Ihe componem. If the individual stru= eomponeDts Ire of elementary data type':!l. you can Pf'X~ lbem witb -normal" LAO or- FBD functions. A JtnJCtUre oomponmt IS accessed ,,~th the nrw:tUfC name and the component name separaIl:
Pa rameter T~l'"
Para.nmerrypes are data I)~s forblock paramo etCI"$ (Table 3.12). The Icn¥t.h s~ifications in Ihe Tahle refer to the memory te«uircments for block parameters fOf function block!. You can abo use Tllit£R and COUNTER in the symt>ol table as data I)lpI:S for timers aud counters. 3.5.1
Unr Data Type,
A uscr data type (UDn corresponds to. S\nICnne (cOl::lb:rwion of COmpoo~'1l1ll of IIDY data ,ype) "ith global "wdity. You can U$C a USC1' data type ifa data occun fte«uenlly in your prop;un or you WIlDt \0 ISStgn I name to _ data stntcture.
=
UDTs have global validity; i.e .. once dec lared. they Can be "sed in all blocks. UDTs can be
3.5 Variables, Constants and Data Type" Table 3, 12
OnTvi~w
of P.""n.,., Typo,
n",n\>ct (tM~ ab,olute a
addrc ssed symbolically; you as,ign the absolute address in the symhol tab le, The data type of'a UDT (in the symbol table) is identical w ith the absolute address. If you want to give a varia ble the data ,(rucrnrc ddincd in the UDT assign the 001' to il at declaration like a ''normal'' data typc , Thc 001' can be abso lu\ely addre,sed (UDT 0 to UDT 65,535) or symbolically addressed. You can also define a UDT for an entire claw type. When progrmnmins the dala block. you ",sign this UDT to the block as a dala ,tNeN,." The example "Mes:lag~ l'rame Data" in Chapter 24, 3 "'Bricf Description of the "Message Frame E:
In the STh-fATIC Manager: select the Blocks object in the 1<:1, pan of the proj en window, and create a new UDT ",ing iNShRT"'" S7 BLOCK ..... DATA T....PL You an: th~-n provided with the attribute, window of the data type . On the "General _ Pan I" tab, emerthe
L>
In the program editor: use FILE -) NIlW to obtain a Jialog bo:< in whieh you can enter the dcsired data type (the absolute address UDTn) under ·"Obj~C( namc".
You can fill in the block header immedia\~ l y when c1'cating the data typ~, Or enter the auribut~' later. With tbe data lype open. you can program subsequent e:
The initial va lue, you program in the UDT a", tra1)sf~11'ed to \h~ variables 3\ dec laration.
Bas~Functio",
Basic Functions
Thi, OIeClion of the book describe. !bose functions of the LAD and FBD proi"'TDIDinS lang uages which r~fl'sent a ~~rtlIin '"basic functionality", The,e funclion~ s ilo'" you to pro· gr.lln a PLC on the basis of contactor or relay ~ontrols.
In a ladder diagram (LAD), Ille onang:erocnt of the COntactS in H r ics and para Ud cirelli., detemurt<:5 the combiru.Di\ of binary sig""l s-.te5. In a function block diasnm(FBD), boxes analoi\Olli to d.'Ctronic $witchtllg system, repfl" $CDtthe b oolean fu nction s AKD and OR.
In ChapteT 5 Ml\.femory FunclionC you ",ill fmd .. programming e:otample for the binary lo~k o!><,,,,tions and memory functions. and in Chapter 8 "CounterJ", an example for lime!'!; and COunters. In both oasts, Ih e e:otumplc is in all FC function without block pflnimeleo_ You will find the same examples is function bloc"" (FBs) with block parameters in Chapter I~ "'Block Parameters"'.
TI,e mrmory functions hold Onto an RLO >0 that it can, for example. be scanned and processed further in another ~ oflh., program_ 'Ote mo" e fUl\ crio ns arc used 10 ",,,,chanKc the values of individual opcran integrated in the CPU allow you, for uan'plc. to proa:ram waiting and monilOrinS ti mes.
Finally. the co un lers can count up twd down in Ihe range 0 to 999. This seclion of the book describes the funenon. (or tbe oJX:r .. nd are'" for inputs, OUtputs. and memory bits_ Inputs and outputs arc the link 10 the process or plant. The memory hi" corre_ 'pond 10 a""iliary con!aclOrs wh ich
''0
,
Bina ry Logi~ O Pf nllons Stnes and parallel circuits (LAD), AND, OR and exclusive OR functions (FBD): negauon: lakino: account o f the sensor
"IOH funellons 1'>IO VE box, system !'unctions for IDO\ ing
do. Tim ~n
S1.artmg 5 different kinds of timer. resetnng and s.eannini I timer. IEC liIn.ers
•
Counton Setlwg a coumer, up md down counlin&; resetting and .scannmg a counter, lEe cOunters; fud eXlllnpic
4 Binary Logic Operations
4
Binary Logic Operations
4.1
Series a nd Parallel Circ uits (LAD)
Binary signal state< are combineu in LAD through series and paralle l connection of contacts, Series connection corresponus to an AND function anu parallel cOllllec ti on to an OR function. You use lhc COntacts to check the signal states of the following b inary operands: m~mory
t>
Input and output bits,
t>
Tim"", and counters
t>
Global data bilS
to>
Tcmporary Io<;al dala bit.>
I>
Static local data bits
I>
LAD has tWO kinds of eonta~t1; for scanning bit operands: the NO contact and tbe NC contact,
bils
Starns bits (evaluation of calculation suits)
,,0
You can reference an operand via a contact using eith~'T an absolute or a symbolic addr~'Ss, LAD uscs onlyNO comacts (scan for signal state " 1") and 'NC contact'; (scan for signal stme "IT) , A rung may consist of a single ~omaCl, but it rru,y also consist o f a large number of contact. cmmected togethe,. A rung must always b<: terminated, for example witb a coil Thc coil controls B binary operand with tbe RLO (the "power flow") of the rung .
The example, shown in this chapter ~a n be' found in fun cti on blo<;k FB 104 of the "B a, ic Functions" program in the "LA L) _ Hook" library that you can download from the publisher's Website (_ee page 8). For incremental programming, you w ill find clemen\s for binary logic operations in the Program El~ment Catalog (with VLEW -4 OVERVlfWS lCtrl -KJ or with I~SERT -4 PROGRAM ELEML'
4.L.1
ically a_ possible to "contact c losed". " power flowing", and "coil energized" , If "power" i, flowing al B point in the ladder diagram, this moans thlll the bit logic combination applies up to this point ; the result of the logic operati"" (R LO) is " I ", If "power" is 110wing in a single coil. the coil i< encrgi~cd: the asso<;iated b inary openmd then carries signal state ·T·.
1"0 C ontac t and /li e Contact
In order to expla in the bit logic combinations in a ladder diagram, we will refer below a, graph-
'-';C contao.
Bin ary operand
- I I If-Binary opeI';md
-I.1f--
N ormull}' open (NO) contact A normally open contact ~OtTe5pon u~ \0 a "",an for signal
The cxample in Figure 4.1 (l~ft side) s hows sensor Sl conneClcd to input I 1.0 and scanned by an NO COntact, If sensor SI is open, input I 1.0 is "0" and no pow~r flows through the NO contact. Contactor KI. controlled by output Q 4.0, does not ,witch on . If sensor S I is now activated, input I 1.0 ha< signal statc "T', Power flows from tbe left pow~r rail through the NO contact into the coil, and ~onta~tor K I, which is conne~ted to output Q 4,0. is aClivated , Th ~ 'NO contact ",ans the input for s ignal state "1" and th~n c1o'e~. regardless of whcthcr the sensOr al the input is an NO or NC contact.
/Ii ormally closed (/liC) con tMct
Power flows through an NC contact if the binary operand ha, thc signal state "0"', If tbe
'"
4 Binary Logic Operatiolt'l
Mode of opfrat1o . of tliO contact
,I
,
"
"
~H-r~
Figure
~ .I
,I
SM''''
octivat.d
'0'
,
--
" '"
' 0'
"
,,<>do of &!l •.,.tion of ~C contact ,, ~
oc Wa'~d
" '0'
T
r-w-r}- H+--ri- Ht-r}"
" '
~
T
'"
' 0·
NO Con",", and r--C Contoc",
signal state is "I ", an NC cOma" "open." and the now ofp<)W"," i, interrupted.
SCt to "I ". In all otber case" no pmvcr flows and tile (Jpcrand Coill is reset to "0"",
!n the example in Figure 4.1 (right 'ide), power tlow" through the NC ~ontac t if sensor S2 is not dosed (input I I , I has , ignal ,tate 'il"). Power al.o flows in the coil and energizes comaClC>r KlatoutpuI Q 4 ,1 .
"C"twork 2 shows a serie, circuit w ith one NC contact. Power tlows through an NC contact if the associated opcmnd bas signal state " 0" (that is. (he NC contact is not activated). $0 jXlwer on ly I1,JWs thmugb the ,erie, circuit in the e xampl~ if the operand ConltlCt4 has signal state "I"" and the operand ConmcI5 has .i g-nal >!ate "0""
Ifs~nsor S2 i, now actiwted. input! 1,1 has ,ig· nal state ' T ' and t~ N'C contact opens. Thc pow~r flow is intcrrupted and contsctC>r Kl relcases.
The NC comact checks the input for Slt:llal stale "0" and then ..,mains closed, regardless of whelher the senSOr at thc inPUt is an NO or NC contact (also see Chapter 4 .3 "Taking Acc ount of the Sensor Type") ,
4.1.2
Series Circuit'
Tn series circuits , two or more contact, are connected in series , Power n(J"s through a series circuit when all C, If the aswc iatNi operand, all have signal Slate "I " (that is. if the '\10 COntaCtS are activated), p<)\\er flows through the rung to the coil. The operand controlled by the coil is
m
-l .1.3
Parallel Cireui"
\¥hen tv.·o or more contacts are arran~ ed one under the olhe" we refer to a parallel d rcuit Power flow, through a parallel circuit if one of the contacts is closed. Figu:-e ".2 shows a typi ca l parallcl circuit. In n et" ork 3, the parallel circuit consists of three contac!>: any binary operands can be scanned. All cont~cts are NO contact" If one o f the opera.nds has signal 5!atC " I", power flows through th . rung t(J lh ~ coiL The operand ~oDrrollNi by lb. toil is $elto "I"", If all operands s<:ann cd haw s ignal statc "0", no power flows to the coil and the operand Coil3;s resct to "0" Ne!" ork 4 shows a parallel circuil w ith one NC contatt . Power flows througb an NC contao if the associated (Jp~ra"d is "0", that is , p<)wer flo"s through Ihe series circuil in the example if the (Jp orand Contacr4 has signal stalC "1" m the operand ConractJ has s ignal , tate "0".
4.1 Snies and Parallel Circuits (LAO)
SerI....ntctlop NlICWOl1< 1 tact1
H
I
""".~
II
"""~,
II
( }--I
C.",.,,, Coo_",
I I
H
Contaclt5
I
f1
C." ( }--I
I
Contact4 ContactS
COO,
I
~,
I
,....n.,.on._ No...,.' C.-,
"""_
""")
I
Contact3 Colt3
N,twork .. Contact4
J~t5 I I
CO"
LAD. you can ,I..., program a brancb in l~ middle or lhe nmll (for an e~ample. see figure 4.3 network 8). You thell gel a jXlralid brallch tliat does Ilot begin at the left power rail. u~ of LAD proifDm elements i. restricted to thi s parallel branch: your altention i, drawn to this in the rcl~V8nt chapters. An ··open" paralle l circuil is called a ··Tbrallch··.
( }--I
Contact4
ContaC1S
co.
,
I I
I I
I I
Coo.",
Contact3
I
I Cl
Coltl Nelwork 2 tllC14
I
I
"""~,
CoO'
I I
I I
I I
• • •
I
I
.
I I
W
Co nn fctlng se ries cin:u; ts in PUlIUC'
Instead of COD lac IS. you can also alTllngo smell eircuils one under the other. fiSIlre 4.3 , hows two examples. In network S. power flows inl.O the coil if Contact! and Cmi/act] 8r.:= clo~d or if Ccmlllcd and Conf(J,"f4 Me closed. In the lower rung (~etwork 6), power flows if ContactS or Con/ac/(j alld Con/oc/ l or Contoct() are dosed. CCl nnr(tinK pa raUtl clrcultl In urltll
4. 1.4
Combln.t1nns of Binary Logk Optr.lio n~
You can combine series and parallel circuitS. fOT example. by RlTllnginll several series circu!ls in parallel or several pan.llel circuits in s",nd. You can ~ombine series and parallel circuits even when both types are complex in nnNre (f igure 4.3).
Instead of (ontacts. you can also amonie parallel dftuits in series. figw-e 4.3 shows twO examplle"5. In net\\·OTk 7. power flows into the coil if dther ComClctl or Con/CleO and eilher Confaef] or Comact4 ..re closed. To ollow power to flow in the lower e.umple (network 8), COlI/aefS. ContCIctO and either COlllact6 or COli/aeO must be clostd.
.. Binaty tA&ic Opennionll
P • .-.JId "' •• ..,110. N_ _ 5
t§""'
I ."".on I
~h.r leo
"""'"'"
~r- I
-~.
"""""' """"'" I
"""-
,
"""n.."Io ••
"""""' I
CO.
( )-----1
"'")-----1 ,
Strlt. «a .... dom ..r ... ~
II""' Con~r4 I -_. fl'" I ~: I Ii" N_....k7
Co-_
4. 1.5
l\"l'11.a,in& Ihe RlMIult or,he Logic Ope rallo n
The l\"OT COnlacl llfgaleS the RLO. You can use this COOIaCI. for c:ltample. 10 rv.n a HTles cir<;;1it negated 10 a coil (Figure 4.4 NfI"oR: 9). Po"cr
will then only now in'o ,he cOil if wrc is DO JIO""cr in the r-:OT contact. tha i is. if ei!her COnlaN}
The same applil:;l by analogy for nel"ort 10. in which a NOT con'ac' il insened after a paraUd cireuil. Here. CoillO is SCI ,fnelther o f the con,acts i~ closed.
You can insen NOT in~lead of anoth"" comacl inlO a branch that begins .t the left power flOil. Insening a NOT comact in a paNnel bnrnch ,hal begin~ in the middle of a rong is nOI permissible.
,"
CoO'
( )-----1
CcWIO
( )-----1
4.2
Binary' Logic Operations (F BO)
In fBD. the logIC opennions performed on binary signal stalO'S take.1>c form of Al\"D. OR and Exclusi.-e OR functions. The operands wbose signal S13IO'S you wanlto scan and combine "'" wTineo a1 tbe inputs oftbesc functions. You can SCan the following operand.: :>
Input and output bi". memory bits (discussed in this SCC1Ion)
:>
Timers and counters
I>
Global data bus
I>
Temporary local data
I>
Static local data bits
~
Status bits ((valuation o f calculation
bil~
re"ult~)
E,ttY binary operand Can be addressed absoIUI~ly o. symbolically_ Wh~n
4. 2 Binary Logic Operations (FBD)
NOT CU Dta ~'
(n.~ a t<
Roul, oflh< 10::1< 0
N"twotil 9
I
Co~taC!1
Contact1 Coct2
r-nf--~II
Coil9
INOTrl---<(
)--I
Coil9
N"twori( 10
t§
-<
Coill0
Contact4
1
FI~ u c"
Contact4
4.4 Exomplcs ofa NOT Contact
In FBD, you PWIlflUIl one binary logic cireuit p"r nenNork. The logic circuit may consist of on ly one or of a vcry luge nnmber o f in tercon_ ncc!~d functions , A logic cirenil. or logic op;:ta1ion, mu st always be lenn inated, for example wilh an assign ,tmement, Thc assign controls a bin aryorerand with tho ",sult of the logic operation. Thc examples sh own in Ihis chapter Can be fOllnd in Hmet ion block FB 104 of the "Basic FunClion5" program In the "FBD_Book'" library that you ean download from the publishers Website (sec page 8) . For incremental programming, you "'illtind the elemenr; for binary logic Qpel1llions b. th~ Program Element Catalog (VIEw -4 OVERVTEWS [ClTl - K] Or with iNSERT ----> PROGRAM ELE).fB.'Ts) unMr "Bit Logic". Ele rnen l ary Binary Logle Operation s
FBD uses the binary function s AND, OR, and Exclusive OR. All functions may (theoretically) havc any num));;;r o ffunction inputs, If an inpmleads dir~ctly to th~ function element, the sign al stale of the orcran d leanned i, u,ed directly in lhe logic opcrntion: if the input has a negation ~hara eler (a circle). the sib'llal sta1 e of
I
Contact3
Co~1 0
•
operan d, or wi thin a binary logic circuit, you can negate the result of the logic operation with the negstion symbol (which i, a circle) ,
4.2.1
..
~
OO.~ct3 NOT~I__________ ( )--I
1.
,,!
I I
Contact2
.I
=
r
thc scan.ned operand is negated prior to exec lltion of the logic operation (see below).
OR
fu~ct!on
~XOR
Exo!m;w_OR fUDe';""
Th e numkr of binary ftmctions anu the scope of a b inary function are theorel ically unlimited: in practice. however, limits are Sd by the length of a block 01' Ih~ size of the CPU's main memory.
Scanning And u,il:ning signal states Before the binary functions perform logic operation, on signal states, they scan the binary operands SliMe function inpllt~. An op
be Ica nned for " I" or "0". lf scanned for "I", Ihe function inpu\ leads directly to the box, A ;;can for " 0" is re cognizable by Ihe n~gation character at lhe function input. Cb«L fo< .j~nol ll .t . "
I"
Cb« k for ';~D .. I.!a!.
"0"
----1~ ----1L_
A sean for "I" produces a scan I\;stdt of" !" " ,hen the SIgnal slate of Ihe binary operand seallIled is " I "; it prodllce, a scan result of "0" whcn the s;gnal slale of the binary opemnd is
4 Binary
Logi~
()p<:ratiuns
Ch""k fM .lgDal.I ... "1"
,, -\1
•
" " "'
11 .0
Function box
fI~~""
4.5
S c ~nniDg
C bd.: fo r . ignal "at< "0"
,I
s.n.".. -~
~,..l
" ' 11.0
-,Fun ction box
"
.....,,, -\1
&.01.01
..clN.",d
" .,'
'"
'"-,-
!t.1
"
Function box
Function bo"
for Signal Stat. " 1" . nd 'V '
"0". A scan for signal state "0" negat ~, lh~ ,can re,uh. that is, the ,ean result i, " I" when the s tatus ofthe binary operand ,canneJ is "0"', The binary functions combine Ih~ sa", I<,s,dl. which is. at it wcrt:. the rnult appt:ed '"direclly" to th e box. As far as fun~tionality is concerned. th~se 1WO m~thoos ofscsnnin g binary operarnl> allow you to treat NO conlacls and NC contac ts identically.
Here all example : "0" IS applied to !he input module for a non-activated NO contact (Figure 4 .5). A scan for ' ignal ,late 'T' forwards this smlus to a funct ion oox. T" effect the same for an N C contact, you have 10 ,can an input wilb an NC contact for signal state " 0" (mu>! includ. a c ircle for negation), The signal state " 1-applied to th c input module for a non-acti,ate<;i NC contact i. then ~onvened into ,ignal slate '"0" at the function bo" If you now activate bolb th~ NO and XC contacts. Ihe function bo" will show signa l 51at. '"1"' in both cases. Additional infoImation can be fo und in Chaptcr4.3 "Taki ng A~ "Junl o f the Sensor Typ""'). You ntust always co::mcct the output of a b inary in the simple,,;! case, sirup ly conn""t tbe O" tpUl to an A"ign box (also see Chapter 5 "'Memory Functions '). With Ihis r ~sul! of tt,e logic operation, yo" c an also , (an a timor, . ",eo cute a digital operali"n. call a b lock. and", on. The nellt cbapter p rovide, all thc information you need. fun~lion ;
To assign the signa l "t~tc " f a binary operand oJirttlly to another biruuy operand wit.llOU\ per_ forming any additi onal logic "peralions. for nample to connect an input directly 10 an out-
uo
,I
put. Ibe AND function is nonnally used, although it would also be possible to use an OR or E,cl~s j \'C OR, S , an ...-jtb~"t l<>'Jk UP ~ t~liOD
8. I I {:Jc:}-----["~'E"":J
ir.put ---j
Simply sekct the AND function, conn~cling only one function input aod removing tbe other, A"l) function
Th e A};TI function combines tv.-o b inary states with one "nother and produce. an RLO of "I"' when ooth Slatos (both .can resulls) arC "1". If the AND function ha, seyer.. t input'. the scan results of all input' must be .. , " for tbe collecti, e RLO 10 be "'1 -- . In all (}\h~r ca,~" th~ Ah'D function produces an RLO o f "O" at its funct ion ontput. Figure 4.6 shows an ~xample of an AND f uncrion. In 1\et\1.-nrk 1, the AND function has three inPlOtS. each oj' which can be connected to any binary operanJ . All operands are scanned for si gnal ,tate "'I '", SO lhat the signal state of the operand, is directly ANnOO. lfall the operands thaI were scanned h ave a si gnal state 01" ' 1", the ANTI function ,~IS th e operand Olllpllll to .. ," "ia the A ssign box (sec nex t clwpter) . In all olher cases, tho Al'-.'D condition is nOt fulfilled and op-."'1"and O,I/putl i, res~ : to "0" . Nen~otk 2 shuw\ 3n AND function w ith a negated input . Negation of tho inp ut i. indic'a'cc1 by a eirde . The .can remit for a negal~d
42 Binary Logic Ope ration. (FBD)
A.",' n fu nction
,
Netwllrl< 1
Inputl
I
Inputl
Input3
Outp
l"l'ut3
Inp
==d , ~ OutPUt2
I
,
I
I
',I
,
" ,
I
Input4 Input5 Outpul2
I
InpUl l
I
I I
I I
OR fu"
,
I Network 3 Input l
~""
OI.ltpul3
InpuO
Inputl Outp"O
Network 4
I nput4 ~
> I
l"put5
~
Input4 OU\j)IJt4
I I
Input2
In;:>ut2 -
E ~du. i,· . _O R
,
I
Outpotl Network 2
,
-' 1 ..
I
Irwu t2
Input2 -
.....
I
,< I
I I
I I
I
""""
,,
I
I
I
Outpul4
O ·
I\tncr1on ,
Netwllrk 5
Inp"tl Inpull Network 6
Input4 Inp ul5
I'i~ur.
~
,~
~o...lPUt5
=:d. xoe ~OUtput6
Input t
I
Input4
I I
I
I
I
,I
I
, 1 ','
I
Input5 Outpu\15
I
I
Input2 Outpu l5
I
I
I
mi
4.6 Exa mples of Binory f unction:;
opcranu is " I .. wh~n thi s operand is "0'", that i" th e Al\'D condition in the exa mple i;; fulfilled when the operaodlnput4 is '" I'" and the operand / Ilpu rj is '"0 ", OR function Th e O R functio n combin ~s two b insry ~ignal ,tates and relu rns ,m RLO of ' T ' w h en one of Ihese statc; (ooe of lhe scan results) i , "1 ", If d,e O R fu nction has several inp uts , Ihe scsn re , u lt of only one inpm n eed be " 1.. in order for
the result o f t~C logic op~ralio n (RLO ) 10 be " 1'", Thc O R function ,<,turns an !{LO of " 0 " when Ihe scan result, of all inpU1S are "0'" , Figure 4, 6 sh ows ao e xample o f an OR function, In ' ktwork 3, the O R functi on has three inpllts: each of these inputs may be connected 10 any binary operand . All op~rands art; scanned for signal s tate "1 ", SO th at the . ign al , tate of the operands is d l,<,c tly O Re
137
• Binary Logic Opt-nliom
Outpull 10 "I ". If 1111 of Ihe open1n
ii "']"' when that operand i. ''0''. IhaT is. 'he
Exclusive O R condition In the ex.unpl~ is ful. filled " hen bOlh inp Ut op.,mnds hav~ the sMIle signlll SllIte.
Nelwork 4 sho"'" lin OR funclion with a negated input. Negation is I"<'pr=!ed by a circle. The scan resuh of. nCJ>IIu,u operand is ~I ~ wben thaI operand is '-o~, IIIaI is. the O R coDdi_ li(," in the example is fulfilled ,,-brn !be oper' and /flpUl 4 b~s II .ignal Sgle of"!" or Ibe operand J"pl
You Can aoo program an l:ac1usi"e OR func{ion " 'jth _ than two inPUl5, in ",hi~h case the exclt.t>i'e OR condiuon is fullined (in the.ea.;c o f I direct <;can) when an une\~D number of the ope"mds ...-.umed rove. SCan n:suIt nf
Eadu.lve OR fu nction
~.2 . 2
The Exciu,ivc OR funclion combi nes 1"0 binary states w;lh one anolher and I"<'ntms an RLO of "1 ~ ,,'~n t~ IWO Slates (scan result.) are not the same. and RLO ~O~ "-hm lbe Iwo st~tes (scan re.uhs) an: ,dentieal. Fillll"" 4 .6 shows an anmple of an Exclusi,'c OR funCTion. In z.,ctwork S. two inpulS, both of which are , canned fOI slgnnl ,tate '"I". lea
--I ~.
Combin~tlo nl
¥QU can casily combine binary function. with one another. For ins!!lnce. ~'Ou ean combine SCHllIi A.."' 0 functinns inTO one OR fuOCTion or "HI OR functions intO one F"clUS;"c OR funclion. The number offunttions per 10iliC opcm' lion (per network) ~ theoretically unlimited. The u.;c Q( a ·"T·braneh" in Ii lo¥ic operation gives you additional options. at1(}wing you 10 prnjp1llll mon.- than one output per logic operan<)ll (.ce Chapler 5.2 "'Fl:lD 1:Ioxc~"). You can link me output of one blIW)' function with the iOPUl of another binary function in ordet-IO implcm<:nt complex bmary I~ic operations. Figure -t.; prm'id6 a nwnber ofexmnpies.
•
,
lnpout1
,""'" Inpout3
'OR OU:pu\8
,..,...,
.., I
Inpu!7
•
~,~
~
of Sinn)" Lo"k
O p~r"llon l
•
4.3 TakinJl ACOOWI! o f me Sens<>.-1'ype
NAND fUn crioD
,
N. twork 7
Input!
~ """"
'""'" r.l><1lo.
..,
N. I _ 8
Input4
,
,
Inpul6
I I
I
I
I I
,
rqIOl'1cd.
Network 10: You can link arbiuary function inputs with binary funetion$. fQT example you ciln place an h clm; .." O R function in front of the second input of an AND fuoction Network II: Using the negation symbol. you negate the RLO. eVen belwe,," binary funclion!, for instl nce you can negate the RLO o f an O R function and use II as input 10 an t\l'.'J) function. N~Bting t he Res uh Logic Operation
oft h ~
The circle at the inpul err output of a function symbo l negales the =uh o f lhe logic operation. You Can use negation ~
to !.Can a binary operand. whicb is equiva_ lent to scanning for signnl slate " 0" (sce abo,·e).
to
beru'ecn two binary functions (which is equivalent to nc=gating the =ult oftbe logic operation). or
~
I
""'~W -,
NetWork 9: You are monitoring the limit switches at the ends of an X axis and a Y axi •. These limit switches may not be actuated in pairs; otherwise. limil swileh error will be
4.2.3
I I
I
0'''''''' Input5
"""",W
I
I
'-"
Input5 Input6
Input3
I I
Input2
Input2
NOR
I
InpY I1
at !be output ofa binary function (for exam· pic if you wanl to set Of reset a binary operand wben the condi tion is not fulflllcd, that i" wh en RLO . MO"),
A nellation may not immediatel y fo llo w a T-
branch . Figurt 4_ 8 shows a NAN D fun cti oll (an AND function witb negated out put) and a NOR function (an OR function with neaated output) , The RLO of a NAND func=tion is ''0'' only when all inpulS have a signal state ofMI", A N OR fu nelion ~tums an RLO of"l " o nly wlKcD oonc o f Ihe ;nput5 has a signal state of "I",
4.3
Ta kin g A cco un l of th e S enso r Type
Wheo scann ing a Sensor in a userprogtam. you must lake account of whetber the sensor i5 an NO eOO~1 or an NC contacl, Depending on !be SCI'I:IOr type, there i. a different siinal stale al the relevant InpUI when the sensor is lICIiv.. tcd: "I " for liD NO contact and "0" for an NC co nlaC!, The CPU has no meanS of dctermining w~ Clher an inp ut is occu pied by all NO contact or by an NC contact, II can only detect signal stute "I" or signal state "0". Prognomm ing wit h LAD lfyou ~trucrurc the program in such a way that you wam ~ scan ~sult of I" when " SCIlsor is actIVated in order to combine thaI SoCBD ~su lt fuMher, you mu" scan the input differe ntly for different kinds of sensOfil. NO cOntacts and NC M
4 Hi"ary Logic Operations
, , , ;'
Cu. 2: On. ~o contaN ond un.l'C
"''',,,''ed , ,- t )
(; • .., I : Bo,h .. n.on a ... 1'0
->
-
" " · 0·
Bolh Hn"""" actlv. ,to
So1/) Ufl;o",
~5j
" .,. .,. M
·0·
-., , . lr " .,." ·0·
, ."" "".,.
-7
-
HH'H HHH'H H H1HH4H H1HH4H 4
1
1
4
.,.
· 0· Con"'ctor
" ~-jllu" 4.~ T~kjng
oontact~
arc
plcl<8 up
"
.,.
· 0·
"
Conr. ctor pict. up
"
Account of tho Se""'I Tn'" (LAD)
a~aiJablc
10 you for this purpos~.
An KO comaCl rerurn "1" if 'Me ,cann~d input is al.o " I ". An NC co ntact return;; "1 -- if !bc ,canned input is " 0". In this way. you ~au al,o
directly scan input' that are to trigger acli, ities when they are "0"' (z~'TO-acti"e input<) and sub'equcmly re-galc the scan n:suit. The ~xampJ" in Figure 4.9 shov., programming depcndent on the sensor type . In (he fint "a,e, IwO NO contacts are connected (0 thc programmable controller. ant! in the second case one NO contact and one t\' C ""uta<;t . In both cas .... '. B conta~Wr conneclcd 10 m OlUput i, to p ick u p it both , enwn; are ac!iva!cd_ If an NO contact is aC liva(ed, (he sig nal ,tale at the input i, "I"', and Ihis is scanned with an NO contact so thaI power ~aO now wh .... n the •• nsor is acti, -ated. If bolh NO contacts a ro a~1:ivareJ, power flows throngh the nmg to the coil and the ~ontactor pich up Ifan NC ~on1 aCI is aCllvatcd, Ihe .ignal sta(e al the inp "l is " 0 " In order (0 have power flow in Ihis e"l'e when the ,en,or i, activated, th~ result Il1U';I be scanned with an NC conlaCt. There· fore, in (he second ca,e, an NO contact and an NC contact mn,1 be connected in series 10 make th .... contac(o r pick up w hen botM senson; are activated. Programmin g with FRD If you "u-u~tun; Ihe progrnm in ,uch a way that you wa nt a scan result of "I" when a sensor is
ac tivated in order to ~ombine IMat . An r-:O contact produces signal state "1" when activated. and i, scanner! dircedy when activalion "I' (h~ sen>Or is 10 produce ft S<:an result of " t "_ An NC contact ,etums 'i~nal stalC "0" wh.... n 3clivaled ; if yon want a scan r~sult of" ]-- when the::-:C eOnta~, is activaled. it mu,( be ncgaled, th"" scanner\. In this way. you can also scan inpm, that are (0 (rigger acti vi ti~s even w hen (hey Mm'e a signal stale of ' -0'" (zero_act ive inpnt,) and further comhinc the scan reSllh_
The example in Fig ure 4 .10 shows sensor typede p"ndent programmint:. In the first C"SC, two 1"0 COma<:l, are e01lllect
4.3 Takinj;; Account of the Sen_ Type
In & l&
'1lH: following memory functions are 8Y'Bilable ~ The single coil as an Ds>ignmcni of the RLO 1>
The coil, Sand R '" individually proi!mmmed Inemory function.
1>
T he boxes RS and SR as memory functions
1>
The midlinc output, as
1>
The coil5 P DOd N as power flow
1>
The boxes P~S and l>."EG ... ..die nalua lions of opC'l'ilnds
inl.<:rmcC; at~ buff~rs
cdg~
c,calwl\ions ofllle
II! Ihe co;!. The n01Cfion of the , ingle coil d"P"llds on the Masler Conrrol Relay(MCR}: If the ~1CR is activated. sian"l Slale ··0'· is n.<~;8ncd to me binary operand loc~ted o,·cr tbe coil. SJmpl~C"'1
Ifpo .... er flow, inlo ilic coil. Ihc opeT11nd is ~t: ,fthere is no pow..... Ihc operand IS re~~t (t"iI.'Un: 5.1 Ntlworir.: 1)_ Wil.b a NOT COn!~C1 before The coil. you re"",r.' e me function (Network 2). YOtl ClO1 nl
~ di~_