You are on page 1of 440

Hans Berger

Automating with STEP 7 in LAD and FBD


51MATIC 57300/400 Programmable Controllers

SIEMENS

HansBerger

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.57400mduding the a pp lications w ilh PROFINET. Speda l lu nciions He PROF INET 1 , SFC 109 Protect and function bloc~< for fieldbu~ !y<; tems <Ire a lso 0 <!e.crim.d. II is 'almed at<lll users 01 51MATIC 57 controllers , First time u se-rs are int""duce d 10 the field of p rogra mmable con1rollers, w h il e advanced USers learn a bmJl ~peci fic applications of th~SIMATIC 57 automation ,~stem. SIMATICiSlh e wo rldl.o'li de sta bljsn.e<l au tomMion syrtem for im plementing indus trial control:systems for madJ;nes, ma n ufact uring plants and industrial pmce,. Releva nt ope n-loop and dosed-Joop comrol tash Me formulated in various pro, 9ramming langllages with the programming software STl;P7 , All programming e xamples found in the book - and ,"ven ~ few extra example' - ~",_available .over tile publishe r'< w eb,ite under Download ....

Contents

Operation pri n~ieje of programmable conl<o l)er,. System overv;'/(; SIMATIC S7 ~nr! STE e 7 - (AD ~"'I FRD pro<Jr~mm;n<J laO<Jua<Jes . Data typ"'. Binary and dig ita l instructions Prog ram seque n ce control User program ,"xewt;on

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

51 MATIC 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" Jl<OiJ1Imming .,.ample. oO<1OO11lnll" on dc",,";bing III<: L"-O .ne! FBD fUDctioll1 and prO~id'"lI SJM,,-TlC 57 _ ... with progr.mming tip. for wiving speclfio ta.k. with this contron.r. Tho programming example. gi vell 1ft the book do I",t prot.n<! to be complete w lut;"", or to be "ne u,.hle on fulu", STEP 7 rolea.." or S7-300/400 ver.;onl. AddilioNll .Ir. mu>t b. talen in order 10 comp ly with 11>0 ",I_ ""ani safely "'liIu l"i"" . The luthOO" and pub'is"'" ha vo taken ~at e,,", wi:h an I~x\l and illU>tnltioos in book. ".".<thel". orrl>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

,hi.

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 eventdriven 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

I'LC functions comparahle to a comactor control sy,tem

Handling numhcN and digi\al operands

Introdncdoll

Ba.k fun<."I1"ns

Digita l fUllctioUJ

Pru~rammabtc

1 SlJ\L\TIC S7-3IJGI4Q(l C"",,.,,Uor

4 BI ... ,), Lo~k Operation.


A.>.iD, OR.nd fxdus;ve OR FUDell"".;

9 Cump.ri..,n Function. Comporjwn Accordu'i 10 Da'" Types INT, DiNT and


~,

Structure of the Pmgrammahk Oll\lmll .. (H",dware Componellts of$7_300(400); Memory Ar"",~


Distributed [10

N""ting t'uru:lions

5 Memory Functio ns

10 .... rllbmetk FUDCtlUOS Fou,-fuooion M.lh wilh INT,


DINT aJ>J REAL numb.:rs:

(PROFIfIUS QP): Cooununiu><ioDs (Sutm.t.), M.-.Juie Addru8C.;

A;,ign. Sci ODd }l.eset.;


Midlme o.,lp"a;

bdge e,-.Iua"oo:
I:.~.tnple

Add,."..,., A,,,,,,
2 ST EP 7 SGR... r.
~: P",&rammID~

of a Cooveyor Bolt

Control SY"t<m

11

Mot~.m.lIcat

.-u.nct1on.

Tri~omctric

FunctiOn>;

Arc functi<m.; 6 Mow FUDction'


Loot! aoo Trunsfer Functions:
~u.ring_ Square_ root hlr3<lion, Exponerrtiatioo,

Ilditiog Projects; Configurina Stal ions; C<)ftfiguring tbe Net""orli:; Syn,bol Edi"'r;

U:>garitlull5

Sy,t= Functions for Data Transfer 12 Com'oT5ign fUDotlon. 7 'f!moro Start SIMATIC Timon with F ive Diffe",nt Ch.,-aotrn.tic., Re ~tting and Scannmg; lEC Timer Function. Data Type C""ve.-.ion; Complement FOImation

LADlFBIf Pru""n &bIOI';


OIJline Mod<: T~tiDgL'LD ODd FUD Pmg ... m.~

3 SI:\-tl\TIC S7
Pm~m

t3 Shift fun<tion. Shifting and ROOIIIn<:

Program I'mce"ing;

Blocl{TyJ>e' :
, ProgralnIl1ing C,><k 1I100KSIlrl<l
1)0", Blocks;

8 Counto ... SIMATJC Counter->; Count up. Count down, SCI, Reset.nd Sc"" Count""'; IEC CountIT Function, 14 Word Lo~i< l'r<:>o;:e;sin& AND, OR and &d""i,'. OR Worrl Logi<: Operation

Addrc.ing V.. iabli;:" Coost""; Rcprc .. otation, Oat. 'r;'PI'; D<:s<ri ption

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.

,
106 FB 101 fB lOS

and Looalln'to"" ...

fa

~ 8

103

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 fB 101 Elmlentary Data Typt' fB 102 Complex Data Types Fn 103 Panomcler Types Basic FunctiOn! FUD Reprcs<:nlOlion Examples Fa FB Fa FB FB 1().1 105 106 107 108
Cbapt.r4: Series and Parallel Circuits

Program Processl n!: Ex.mples or SFC Calli fB FB FB FB 120 Chapto:r 20: Main Program 121 Chapt..,. 21: Interrupt ProcesSlnS 122 Chapter 22: Stan_up Char'lC1eristio:s 123 C~aptcr 23: Error Handlins

Conwyor Enml'l e Examples ufBasic Functions and Locallnstanc~ Fe 11 FC 12 FB 20 Fa 21


FB 22

Chapttr5: Chapler6: Chapter7: ChapterS:

Memory Fl1IIC1ion< Mo,. Functi<Kl.'i Timer Functions CO\If\ter Functions

Belt Control Counter Control

F=<
Con"eyor Belt Paru Counter

Digltl l FunctIons fBD Reprnenllotion Examples FB 109 fa]10 FR 111 FB 112 Fa 113 Fa 11 4 FBD Chapter 9: Chapter 10: Ch.lpter H: Chapter 12: ClLapterl3: Chapter 14: Compari:!Oll flmCliOll$ Arithm~tic func(ions Math FunctiolU Conversion F"""ions Shift Func(ions Word Logic

:llnulIc Fnm. En mpll' Data Handling Examples 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 FC 41 FC 42 FC 43
FC ~

}'ro~r.m

Re~sentalion

Flow ContrOl Examples

FB 115 FB 116 Fa 117 FB 118 Fa 119

Cltap(er 15: Slatus Bils Chapter 16: Jump Funcrions Chapter 17: Mas((1 Control Rday Chapter 18: Block F"",tions Chapto:r 19: Block pll3ffiC(e~

R.ange MoniUlr Limit Value Dc~linn Compound Intere,t CIJculalion Doubleword"",i'le Edge E,.. lualion

Automating with STEP 7

..".

- .

O~"'''ting

......." ,'

proje ct

+
=w~

.'
e

A utomati ng "jth STE P 7 Th is double page shows the basic proccdure for using the STEP 7 programming softv.1lI"e.

L
i"",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.

Use pmject ass istant

Cooflgu ra central rack (select paw-er supply

a nd CPU)

Creat.. Pruj..ct
contain",

CPU MIh DP ma$ter:

~"

al~~~rt PROf' I6US

CD
tnunstaUOrt

, ,,

In the nexi steps. you configure the hardware and, if applicable. the communications conne<:tions. Following this, you creale and test the program.
The order for crealing the aUlo_ malion data is not fixed. Only

1Open Hardware cbj&e1


"~I
~",.

Conf'llU'" expansiofl rack (proceed 8 S for central

-,

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. 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.

rack and CPU


Mark DP m a~t?: I

Sa~ e

and canpi le

insert a ootMr ttatiot1

CD
Project structu re

COOfogUf6 000111 .... s tation

is ""I up

Compiled configuration data ere located In 11>8


object
Sy~

'"

DB/a

Automaling wi,h STE P 7

,
:::~~
Slart netwo<l< conffguration

...
u " . ' p~r"m

...
u"

:f
Compiete symbol tab le Insert miss;"" objects
Incr~~nt81

commun ica~o ns

fJJ

Switch onl;ne

!
load s)'$tem data

SOU'C<Ioriemed pro-

M '

.!
P",ameterlze CP modu les ro lovam Isof(v;.....

1
J

'::;'~

"

Creato program source ~ Ies

, ,

.-

(j)

Define data structur..


De~n"

program structure

1 I
I

P"",ram UDTs afld gk>bal DBs Program FCslFBs, ge""rat.. inUance DBs

Single slep

,
I

Se leCllllodule with "connection capability" and conllgure connections with t~" connection table

Program

08~

,=1
~
.
COfTact e'rors , updata offlin .. database

I ,
Conf'gure " Iobal data communicalions

J p il6 program source fi les

!
Gan era!" rnf...-&nco d ata

j Test n,,~t
;

(j)

Compiled connecti<>n data are Inserted In the object System Dale

C ompile<! progfam locale" in the contain .. ' Blocks

Teste<! and n xacutable program in t he CPU and in the programming dev"",

"

Cont<111<1

Contents

:Jnmidvctl(ln . . .

......

1.1
1. 1.1 1. 1.2 1.1 .3 1.1.4

S IMATIC S7-31111/41111
rro~nmm"ble Controll~r.

"
'"
20
20 20

,
2.1 2.1 . 1 2.1.2

STEP 7

Pr(lgrammjn~

50fh, a re

49

STEP 7 11a,is Package I Illllallation Automation Liern~e Manager SL"-t.'\TIC Marutgcr . Proj ects and Libraric~ Multiproja"1s . Editing I"rojects. Creating Projecu . Managing. Reorgan;~ing and Ar-chiving . l>roj ect Versions C!"""in g and editing tnullipr()je~t~ Configuring Stat ion . Ar",nging Mooule ..

of the Programmable ContruU.,. . . Componenu. S7-300Station. S7..400 Stati"". fault-tolerant SThfAllC. Safely-n:Ltted SIMATTC. CPU M~mory Arcas. Distributed 1 . 10 PROFUIUS l)P

Stru~IUn.:

2.1.3

2. IA 2.1 S 2.1.6 Ocline ITdp . . . .

" " "


53

50

I.I.S
1.1.6

14

" "

2.2
2.2.1 2.2 .2 2.2.3 1 .2 .4 2.3 1.3 .1

"

"
28 28 31

1.2.1 1.2.2 1.2.3 1.2.4 L3

PR QF""mTO
Acruatorl Sensor Interface. Gateways

..

"
Jl

" " " " " " " '"

Communication . Introduction _
SubllCt~

J5

2.3.2 Addr.-ssing Module. 2.3.3 ParnrneterU.ing Module.~ 2.3 .4 .!'-etworking Modules ...ilh MPI
2 .3.S Monitoring and Modifying Modules. . . . Configurin g the Network ..
C(lnfi~uring 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 ....

60 60

!J. I 1.3.2

\.3.3
1.3.4
" 1 4.1

Communications Connections .

Scn~Ce'i.

Madule Add1X'<;scs.
1.4 .2 1.4.3 \.4.4 1.4.S

1.4.6

Sigual Path . . . . Slo\ Addre~ .. Logical Add!""s . ModuJ~ Slart Addu,," . Diagr>oStie~ Address . . Acidre!lK'5 for nus Node;; Address
Art:a~

., " " " " " " "


" " " '"
"

J5 31

H
2.4.1 2. 4.2 2. 4.3

'62 1
62

" "
" " '"
70

2.4.4 2.4.5
2.4.6

68

2.5
2.5.1 2.5.2 2.5.3 2.5.4

Creating the S7 I'rogmn . Introduction. Symbol Table . Pro);I"3ffi Editor. Rewiring Addre. s I'riOOty Refel"l:!l<:c Data . l.no:uage Setting .

'"
71

70

I.S

\.S.I
I.S.2

J .5.3 !.S .4

U ...."T 0lI1li An:.a Process Im.gt . Consistent U ... r Data Ait M~mori~,

76
77

2.S.5
2 .5.6 2.5.7

79

" "

Contents Variables, Constant, and Data Types General Remarks Concerni ng Variables .. Addressing Variables. Overview of Data Type. Elementary Data Types . Complex Data Types Parameter Types User Data Types.

2.'
2.6.1 2.6.2 2.6.3 2.6.4 2.6.5

Online

Mo d~

Connecting a PLC Prote<:ting the User Program CPU Information . Loading the User Program into the CPU Block Handling Testing the Program 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 SIMATI C S7 Pro gram . Progn.m Process ing . Program Proccss ing Methods Priority Classes Spe<:ifications for Program Processing Block s Block Types Block Structu!"<'. Block Propenies . Block Interface.

"' "' 82

"'

"
3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7

" 6 '16
120

2.7
2.7.1 27.2 27.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8

"

"

86
80

'" '" '" ,n


>28

86 87 88
90 90 90

Basic F llnctions . . . . . . Binary Logic Ope rMlon . 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

D'

,.,
4.1.1 4 .1 .2 4 .1.3 4.1. 4 4.1.5 4.2 4.2 .1 4.2.2 4.2.3

'"

'" '"

,
3'
31.1 3.1.2 3. \.3

" "

"

D2 D2

U3

.. . .

94 95

Binary Logi c Operations (FBD) Elementary Binary Logic Operations .. Combinations of Bina ry Logic Operat ions. Negating the Result of the Logic Operation . Taking Account of the Sensor Type-. M emory Function s. LAD Coils . Single Coi l Set and Reset Coil. Memory Box f BD Boxes. Assign .. Set and Reset Box . Memory Box Midline Outputs. Midline Outputs in LAD Midline OutputS in FBD

'" '"
03 ' 038

'.2
3.2.1 3.2 .2 3.2 .3 3.24

" 98
99

.. ..

'"

' 39

3.3
3.3. ! 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7
3A

Programming Code Blocks Open ing Blocks Block Window . Overview Window. Programming Networks . Addressing. Editing LAD Elements. Editing FBD Elements. Programm ing Dma Blocks . C!"<'ating Data Blocks Types of Data Blocks Block Windows and Views

'"' , "" '" ,., '" '"


.08

4.3

'"

5. I I
5.1.3

'" '"

'42

5.1.2

'08
.09

,.,

'" ,44

'" 112

3.4.1 3.4 .2 3.4.3

'" '"
'" '"

5.2.1 5.2.2 5.2.3

'" '" ' 48


"8
' 50 ' 50

' .3
5.3. 1 5 3.2

'"
U

Contents

'A
S.4.1 S.4.2 5.4.3

Edge Evaluation . . . . . . . . How Edge Evaluation Worb Edge EVlIlu.o.Tion in LAD Edge EvaluaTion in fBD . Binary Sealer

'"

7.7
7.7.1 7.7.2 7.7.3

lECTnners ..

.. . . .

180

IS2

'" m '" '"


'62 '62 '64 '65 '65

Pulse Timer SfB 3 TP . . . . Qn..o..lay Timcr Sfn 4 TON . OffDelay Tnner SFB 5 TOt'. Counters .. . . . Progrll.mm ing" Counler Seuing and ResellinJ; Counters. CounTing Checking a Counler. IEC Counl<TS . . . .

'80 '80 '80


18'

" 5.5.1
5.5.2

..

Solution in LAD. So luti(>Il in FilD . Ellample of a Conveyor Control


Sy~tem.

'" .. , '" "


R.2 8.3 8A

'6 6 6. ' 6.'


6.2 .1 6.2.2 6.2.3

'"' ' 85
IS'

Mo\"t

Fun~tlons.

General MOVE !)ox the MOVE Box . Movmg Operands . . . Moving Constants . System Functions for Data Transfer . .
Proc~5ing

16' 16'

163

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.'

'"

6.3

6 .3. 1 ANY Pointer . . . . 6.3.2 Copy Dala Area . 166 6.3.3 UninlemJptibte Copyi ns of a Duta A~a .. 166 6.3.4 Fill Data Area . . . 166 6.3.S Rcading from load Memory 168 6.3.6 Writing into Load Memory 168

ott)lal .' uoclions .. .. .. Comparlsoo


Fn n~ltons

19' '93 '93


' 97

'"

"
!J.2

Process ing a Comp"ri.f<)n function ..... Description of the Compllri:SOll Functions . . . . . . . . Arlt hmetir
Pnxe~.iog Fu n~tl on

7 7. '
7.1.1

Thnrn . . . . . . . Programming a TlITler . 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
(FU D) ..

17' 170 170

"

10.1

an AriThmetic

f unction
10.2 10.3 10.4

.....

.. . .

"7

CalculaTing with Dala Type Jr.'T . CalculaTing with Dala Type REAL. Mathern.lleul Funcll(mt Proc essing 8 Mathematical function Trigonometric Functions .
Arc

Calculating wilb Oata Type Dt"T 200

'"

7.1.2 7.1.3 7.1.4 7.U 7.1 .6 1.1.7 7. 1.8

'71
173

'" '"

'00

II
11.1

7.' 7.3 7.' 7.5 7.6

Pul., Timer .
EltteT1ded Pulse Timer . On-Delay Tim..... Rclcnli\"e On-Delay Timer Off. Delay Timer . . . .

'" '" '" m


'76
177

'"
20' 21)'

11.2
11.3 11.4

FUIIClioDs. . . . . . . .

,\liscdlaneollli Matbmlatlcal functions . . . Con version }'unctlon . Procrssing a COO"ersiOD function

''''

'78

"

'''' 207
. 207

12. \

'"

"

Contents

12.2
12.3

Conversion of [NT and DrNT Numbe rs Conversion of BCD Numbers Conversion of REAL Numbers Miscellaneous Conversion Functions .. Shift Funcdons Processing 8 Shift Function Shift Rotate Word Logic

209
2 10

"

Block Fun ction . . . . . . Block Functions for Code Blocks B lock Calls' General Call Box. CALL CoiL'Box. B lock End Function. Temporary Local DOlO Sialic Local DOlO Block Functions for Data B locks

18. I I 8. I I 18.1.2 18.1.3 IS. I .4 IS .l.5 18 .1.1; 18.2 18.2. I 18.2.2 18.2.3 18.2 .4 18.3

'" m
DO DO 238

12.4 12.5
D

210

m
m m
2 15 2 16

239 2<0 241 2"

13 .2 13.3

'"

"

. .. ... .

14. I 14.2

Processing a Word Logic Operation. Descr iption of the \Vord Logic Opt:rmions

'"
'"
m
220

Two Data Block Regislers 2" Accessing Data Operands . Opening a Data Block Special Points in Data Addressj ng System Functions for Data Blocks .

'" '" '"


2"

Program Flow Control

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
Block P a rameters . B lock Parameters in General

249

2>0

"

Status Bits . . . Descrip!ion of the Slat", Bits Sening ' he S!aIUS BilS Evaluating the Statu, Bi!, Using the Binary Result

15.1 15.2 15.3 15.4

'" "
221 222 224 225

'" '"

\ 9.1

19 LI Defining the Block Parameters . 19.1.2 Processing the Block l'aramcK"" 19.1.3 Declaration of the Block
Paramelcrs

m m m m
253

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

19.1.4 Declaration oftne Function Value 19.1.5 Initializing Block Par"",eters. 19.2 19.3 19.4 19.5
Formal Parameters Actual Parameters . "Forwarding" B l<x:k Param eters
F~amplcs

'" '"
m
2S3

" "

Jump F unction . Processing a Jump Func!ion . Unconditional Jump JumpifRLO - I". Jump ifRLO - "O". Ma.ter Control
R~la y

16.1

m m
228 229 229

260
260 260 26' 262 .269

16.2 16.3 16.4

19.5 I Conveyor Be l, Example. 19.5 .2 PariS Counter Example 19.5.3 Fe~ E~ample
Program Processing .

17. 1 17.2 17 .3 17.4

MeR Dependency . MCR Area MCR Zone. Selling an d ReSClling lIO Bits .

m m

'"

"

Main Program. Program Organization.

20.

'" 23O
270

232
233

20.1.1 Program Strucrnre. 20.1.2 l'rogram Organi~.ation.

'" "

20.2

Scan Cycle Control

272

20.7

S7 Communication . . .

DO DO
332

20.2.1 l'roccss IllliIge Up<Jating . 20,2 .2 Scan L-yd~ Monitoring Tim~ 20.2.3 M ;n;,num SC/ln C yde Tirll<.', Rackground SClInning .

272
274

27S
176 276

20.2 .4 Re.<poru;o: TIme . 20.2.5 Stan infonnatil)f1 .


20.3 20.3.1 20.3.2 20.3.3 20.304 20 .3.S 20.3.6 20.3.7
20.3.~

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.8

m
335 335

3"
339

Program f unctioos

m
27K
2RO

IE communie,uion ..

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 .
Cmnmunication via Distributed I/O

no
282 2K2 2M2 283 286 287 287

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.9

no
341 343 345

PIP c"",",unication with S7-300c 346

2004

20.9 .1 fundsmCfltals. 20.9.2 ASCll driver and 3964(R) pro<edure 20.9,) RKSI2 ~omputer coupling. 20 .1 0 Config'Jration in RUN . . . 20 .10. 1 I'r..paration of Changes in Con figuration. . . . 20 .1 0.2 ChangeCnnfiguT'/lti(l<l . . 20 10.3 Load Configuration . . . . 20.IOA CiR Synchroniution Time.. 2[l.IO ,S I:.ffccts on l'rogram Exe;:ulio" 2[l,10,6 Control CiR Pro<;~ss 21 21.1 21 .2 Inlcrru pt H a n dlln K General Remarks .

'"
347 . 349 352 352 353

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<ing PROFL"'I:.T 10 . 20.4.5 Coutigm;ng PROF'l'NET 10. 20.4 .6 Special FuncHons for PRo.l'1NET 10 .. . .. . 2004 ,7 System !)loeb for Distributed
1/0 .

292

'" 3"
300

3S3
3S4 354 354

314 320 320 322 324 324

356 356

20.S

Global Dma C<.>mmun; catiw .

20 .5.1 Furtdamemalll . . . . . . 20 .S.2 Configuring G O communication 20 .5.3 Syslcm Functions for GO Communicotion. 20.6 S7
l:J"si~

Time-of-Day Inttmtpts .

Commuuicatioll .

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

21.2 .1 Handling Tlme-ofDay 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 Timc-Delay inteTTUpt~ 360

21.3 , I Han<iling Time-Dellly lntcrrupu; . 361 21 .3,2 Confi!(uring Timc-IXI~l' lnt~'1TUf't. " 'ilh STEP 7 . .. .. , . 362 21 .),3 Syilt~m FUtlction$ for Tim,,_Iklay Intcm.lpt~ , 362

"

C()nt~nts

2 1.4

Wakhdog

Int~ITl,pts

363

12.S

Parameterizing Module"
3R6

21.4.1 Handling Watchdog IJl\ " rrupt~. 364 21.4 .2 Coniiguring Watchdog Inlcrr"plS with STEP 7 365 1 1.5 Hardware InteITllpts 365

22 .5.1

21.5 . I Generating 8 Hardware Interrupt


1 1.5.2 S~rvi"ing Hardware Interrupts . 11.5.3 Configuring Hardware Interrupts wilh STEP 7

365
306

Gcn~ral remarks on parameICrizing modules. 22,5,2 System Bloch ror Module 'Paramelerizalion 22.5.3 Blocks for Transm illing Data Records

'88

390 393
;93

23
367 23.1 23 .2

'Error Handling
Synchronous Errors. S}"chronous Error Handling

2 16 21.7

DPVllnterrupts Multiprocessor Interrupt . Synchronou, Cycle Interrupts.

367 369 370

395

21 .8
21
~. l

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

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 23.4 AsynehrotlOl1< Errors SY"em Diagnos!ics.

'"
;oJ ;oJ

397

;97

398

'00
400 400 401 403

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

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

"

Starr_up
G~neml

Char~cteri"tks

Remarks

'" 376
376
377 377 377

23.5

Web Server
th~ lV~b S~"ver

23.5. 1 Activating

22 .1.1 Opera{ing Modes .


22.1.2 HOLD Mod~ . 22.1.3 D i,abling the Omput Y.odules . 22.1.4 Re,mn Organization Blocks

23.5 .1 Readin g Oil! \Veh infomlation. 23.5 .] Web information

Appendl~

..

22.2

4U(i:
.97 "8

Power_Up
Mod~

378
378

22 .2. I STOP

22.2.2 Yfemory Resct 2 2 .2.3 Re'toring the fa~!Ory setlings


22.2.4 Retentivity 22.2.5 Restan Parameterizati<m
22 .3
Typ~,

378

Supplemen{S to Graphk Progrllmmin1:

no
m
379

24.1 24.2 24.2.1 24. 2.2 24.2,.1 24 .2.4 243

Block Protection Illdirect Addressing.

'"

of R~'tHn

380 380 380

22 .3 1 START-UP Mode 22.32 Cold Re<ran 12.3 .3 Warm Restan. 22.3.4 Hot Re8{art.

m
383

Pointers: General Rem<ll"k s A rea l'oi11l~r. DB Pointcr ANY Poin!er 24.2.5 "V"riabk" ANY Poinler BrieflJescription of the -MessHge Frame Example" .

'"' .08
408

"0
410

22.4

Ascenaining a Module Addre.s

'"

ConteDts

"

Bhxk Librari es . .. Organization BI<xks.

......

25 .1 25.2 25.3 25.4 25.5

'" " m
'"

fun ctio n

~t

LAD.

16. 1 26.2 26.3

Bask functions. Digital Functions Program Flow Control . Function Set FIJD . Basic Functions. Digital Functions. Program Flow Control

System Function Bl<xks. IEC Function Blocks S5S7 Converting BI<xks . Tl-S7 Converting BI<xks PID Control BI<xlcs . Communication BI<xh . MisceUanwus Blo ch. SIMATIC_NET_CP .

",
426

'"
'28

'"
420

421

25.6 2S.7
258 25 .9

'" '" m
423

"

27 .1

'"
429

27 .2 27 .3

<3, m
433

25 .10 Redundant]O (VI) 25. I I Redundant 10 CGP

'"
'"

Indu .. . . . . 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<!rihuted without any special setting' or param eter as, ignmems hsving to be madc _ In SIMATIC S7 systems , distributed i/O is an integr,,1 pun of the system . The CPU, with iv; V.u101l.~ memory a reas, forms the hardware basi. for proce ssing of the user programs_ A load memory ~onta iru; the complete user program: the pans o r the program ", levant to it, ex eculion at any given lime are in a "ori< memory whose short acce<> 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.-T" view 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

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

SlMATIC 57-300/400 Programmable Controller

1.1

Structu re of Ihe Programmable


Controller

It II . Iso possible 1000nn~ di,mibuted 1/0 to a l!anon (Ie<: Chapter 1.2.1 PROFlBIJS OF). 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. 1.1.2 57300 Statlnn

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
~

Power supply (PS); Provide!< me internal supply vollag~s Central proce$,ing unit (CPU) St~ and pr""e..." the USef progrnm Interra"" modules (L"-1s); Connect the- TIIcki 10 ODe another Signal modul~ (S'-1s); Adapt the 'ignals from the system 10 the internal signalleve1 or control actuators ... ia digital and analoa: sianals complex or time-en tical processes illdq>end01ltJy of the CPU
E~ecutc

Centnllzcd configuration
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.
I> ,\

t>

I>

> Function modules (FMs);

tv,o-tier configuration (wilh 1M 365 up to I meter l>etween rad,s) or

t>

Communication. p~ (CPs) Establi.h the oonn~ion to subsidiary n<"I_

A configuration of up to four tiers (with 1M 360 and Lvi J61 up to 10 mctm between TIIcb)

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 mod.lIes ,0 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).

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 modules 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

20

I. I Struct ure of the Prugrammable Controller

Modular configuration
of aD S7-300 Stati"n

Four-tier contigural;on wilh 1M 3()ti ""d [~j 361

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_

Loco! r><Li<
","'l.lrn~ i th

1.\1 %()'l 1.\1 <60-<

5V

(N 46\ 1)

"""""',>Coo

1:-.< .{,ll

Loc. l "'1llI" up'u 5m witt""" ~ V


tr:.rwniMiOIl (l\t46 j-{))

R omot<; ",ng<

"PlO 100m witboul 5 V

.... ''<In;'';on
(1M 461 ])

Romot< rang. up (oWO m


""I00U' ~ V

'Oln.m i" ion (1M 461 4)

R range """". fur up


10 WO tll

S5 oxpan>ion uni" (IM 314)

F ; ~u",

1.1 Iiordware Conillt(uMion for S7 ]()()/ 400

I Sn.tATIC S1_300/400 Pro&rvmmabk ControUII'f 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(~

number of modules and the )lOwer consumption ~I!<O apply in (hi, case. S.andard CPU,
~ staDdard CPUs an.: Qvail abk in vern""s lhat difft:r with regard 10 memory capacity and proeeuing speed They IlUllle from the small o:jl" CPU 312 for lower-t"nd applicalions with moderate proce'<.<ing speed ~uin.:rncnts, up 10 \~C CPU 3\9-3 P:\/O P "im ilS larjlc rrogram memory 8ml high pro<.:es~ini performance r"r CroSl-~OC{or aulom,l1ion tasks, Equipped " im lhe ",IC\lant interfa~~$, some CPUs can be us~ for central control of the distributed !lO via I'KOFTBUS and I'ROFINET. A micro memory ~ard (MMC) is ~uired for o~l'Il1ing the .t.I\IIdard CPU, - ..s with all inno,"'ted S7-300CPUs. Th;" medium opeDS up Dew applicali.,," ~ibililies compared to the pm.iously u,ed memory card(,;ee Chapt<;1" 1.1.6 '"CPU Memory Areas").

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 now dis<:omin ued CPU ) 18 can be replaced by the CPU, 3 17 and 319, Compllet CPU.

The SIPLUS product family offcfti CPU, and module, based on the S7-300 tha' can be use d
til harsh 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.<ed requi..,mellls for humidity, condensa lion and frttring. Please note the I.tthnical da1a for the module concerned. SeleCl~ types oft.bc SIPlUS product mnge are "vuiluble on request for use on rolling stock in aceurJancc w ith EN SOISS "Railway applications - [lIectronic ~uipmenl used on rolling ~1<>ck ~.

'''e )"-" C CPU. permit C<>IISIJUcuon of com

pact mini programmable CUDlrOIlLT>. Ikperlding on me vcr;ion. they alrtady contain:


~

In\cgral liOs Digital and analofl inputs/outputS Integral technoi<JiY function,

I>

Counting. mCaliurcmCIl1, control. po,itiooing


I>

Integnol communic~lions in'crfaccs PROF1BljS OF masU:T Of slave, poim;.,.. point coupling (PIP)

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

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

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.

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 4632'8 two interface,. Fault_tolerant SnlATIC

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

1.1..1

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 57400HlFH. 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.

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 7012 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 .

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.

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 Fmodul 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 7400 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 ""fetyrelevant 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

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!<Cd in p lants with incr,",sed safety requirements. T he ""fety requjr<.:m~'11ts achievable with SIMATIC S 7 are : Safety Integrity Level SIL I III SIL 3 according to lEe 61508, Rc,!uin:mcnt Category A K I to AK 6 according to DTN V 19250 (DIN V VOE 0801 ) and Category I to 4 accord ing to EN 954L The safelY functions are located as appropriate in the saf~ty_related user program in a correspondingly designed CPU (f-CPU) and in the f31lsafe inputs and outputs (F-modu\es and F_ .ubmodules, sec "Fai lsafe I/O"). The ""fcty technology with F-C PU and f-rnodu les (for the safety_re lated p lant component.) c an be int,,!,'mled in an S7-30014OO P LC in additi on to the standard application . Safety-related communi cat ion using PROF!BUS DP applies thc specially developed PROFlJ:l US protl\ e PROFhafe . Th is permi!> 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.

library

~<Ul

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. 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. "ailsafc 110
1b~ fai lsate signal modul es (F-modules) are require<! for ,afe'y <)p<..--ration in lhe failsafe ,ystem,. Fail safery i. achieved with the ;t\legral ",fely fu,,"tioru and appropriate wiring of th" serums and acl\ill.ton;.

uratioru), and fmther projc~l-specijic d" ta ,uch as symboltahle, and comments. Tne Qnlin~ dafa "o",ist of the mer pwgram and the system data on the C PU, and are ac com m<Jdoted in tw<) areas, namely load memory and work memory. A.i>o 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. T he cpe s have a slot for a plug-in ",,,mory ."b, "wdu/e. The load memory, or pans thereof. is 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

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
>

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.

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

C PU l\-Iem ory Areas .\licro


m. mo~'

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-

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

P~le

Canlrolkr

.... .~

Hardware

I d.ta t>k>cks r -f--ff (contlguration


dataonlinel

System

Sym~

+ll<.

Arcnive<l
(compressed)
~data

'""

Paru

01".,. hlgllNghred

.,... """ IN PfjratnftIei1z9d In CtIn.In CPUs.

PleNa nolO. "".,. _

InllRUp!

momc:wy _

syslfNn

memotY~.

1ncre.S& '.Il'. In IhI!


In redlJClion

commotl ph.,.;c.l memotY 1ft

.re.

r ". compl~t6 proj6cr dllrll can btJ ioadfHj in rhfJ archIVed stat. kim ".,. CPU'~ load """""Y. If """ssaiY. ltMly""" be_lOthe
ptOgT1ImmIfIf/

$}'$Iem memo.y rowns


in tI>e

TIm ... funclion$

""'" """""

.JIe,

do'*" on _-..d.

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 1 create a 0 measured-value arcbive 00 lh~ MMC Bnd to provide it witb data.

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

I..oM memo ry d
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

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

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.

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-

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

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 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

I $IMATIC S73OO/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 System memory

l oad mamory RAM and RO M

57300 and ET CPU. w ith adjustable data ret.ntlvlty Micro "'.,," ca r<l Loadma mory RAM and ROM

,C,'"'--_____________________ ,
Work. mamolY Prog ram code User data Sy"em memory

non-ret&ntive Us-erdata
fele~tive

5 7-400 CPU M&m CI'lrd Load memory AAM

C'"
load memory

RAM

Load memory FEPROM

Work memory Program code

Systam ..... mory

Work memory Use r data

Figu .... \.3 Phy<ical Design ofepe Memory

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 S7400 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 T he 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 nemork A DP master can control a number of DP , laveo spec ific to it.el f. You

1.2 Disuibtne<! I/O

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.

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) An interlace module in colijunction wilh a CPU (e.g. 1M 467) A CP in conjunction with R CPU (e.g. C P 3425. CP 443 -5)

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 .<Iaves. elc. You can n.-dUCt Ihe response rime ira OP master system contains only a few OP sla\,("5. SinCe II i~ possible 10 opcrau: ~c"~TaI Di' IILIIS\("f$ in o~ S7 stalion. you can distribute the OP sllt'-es nfa slation o'-~-r >c'~,.,.1 Df' mailer '~Slcm$. In multiprocessor m<><k. eve')' CPU has its OWII Dr maSTer s)'Stems,

t>

to

The,.., are "Class I ma<tcn" for data exchange '" proceso op"rntion and "CIIO$$ 2 maSTers" for <ef\~c~ and diagnostics (e.j. a pNgTIlIDmiag
de"ic~)"

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

> Mod\dar Of' sla""" Th~y comprise severnl moo.lulcs (submodules)


t>

Tntelligent Dr 5Ia,"("< They contain a tnnJl'ol progr-am lhal trois The lower_level (o",n) mndules

COfI-

S7 ".floa "ltb DP ",,".r,

c=-~., .w.

<-8. Io--r 200Et

[)rlL)r

PROflBUSDP DP".. DPRSnlC link


DPAS-ln~

LiDk

'I

50",,! roD1I1;""

9,.. "'-'pr>tflu ... ~b Ii.... dioJII"'lk.

Fillurt 1.4 Comron<n'" of 3 PROFIBUS Of' Masltt SY'l<.m III lin RS4~~ sCiln.m.

I SIMATTC S7 3()(1!4()(1 Programmable Con""lIcr

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 ET200LSC (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'.

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

Modular PROFIBUS DP Jlave.,


The ET200M is an example of a madular DJ' slave. The design corresponds to an S7300 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 1533 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 1517 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!!.

1.2 Distributed lfO

S FC I READ_CL K Rnd transmit it using SFC $8 \VR_REC or SFB 53 WRREC.


The {hasno~tic. repeater is configured and parameterized using STEP 7. A GSD file is available for opemtion on non-S~tAT!C ma.-

> A CPU with integral PROflNET interface


(e.lI . CPU 317-21'1'0101')
t>

A CP module in conjunction with a CPU (e.g. CP 343-1 )


dl" i e~

,=.

10

1.2.2

PROFIN ET 10

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~
ET200M. ET200S and ET200pm. The gateways PK'PN coupler. IE/PB link and IEiAS -i link nre 1l1so 10 d~vices.
10 su pHviSQr

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.
PRonz., I::T 10 system
A I'ROFINET 10 "ystcm comprises th~ 10 con_

10 supervisors arc dc\ ices for paramc'erization, Startup, diagnostics. and human machine imcrfacing, e.g. progmmming devi""s or HMJ de,ices.
1.2.3
Actuator/Sensor
lnlHrac~

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:

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).

The Actuator/Sensor interface (AS-i) ;s

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.

IE/ PR linJ.

I SIMATIC S7-300/400 Programmable Conuoller

"

PROFmUSDP

Indy,niol Etheme,

~ link

ASi IE/AS-; li"k

AS-i a<tu.""

AS-i .emo,

AS-i d"tributor

B;""'Y actuators a nd n<Ol'S ",';'0 ASiAS IC

Binary "motor< 000 S=or< without ASiASIC

runhc:r AS; do,'ioc,

FIgure 1,6 Connecting the ASi bu, 'ystcm to SII>lATiC S7 With "ASlnterface SafelY at Work", you can safety sensors such"" em. rgencY-<Jft' switches, door contact switches, or ",fety light arrays direct to the AS_i network up lD Category 4 in accordance with F.'I9541 Or SlL3 inaccor dance with mc 61508. This requires safe ASi slaves for connecting th~ ,afcty smoors and a safety monitor that combines the safe inPUIS with parame1erizable logi~ and ~nsures safe shut. down.
~onne~1

o module: It occupies 16 input bytes and 16 out

Inslandard mode,lh<' CP 3432 behaves li ke an l'

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 ASi Sla'"C8 are paramc teri<ed wi1h default valllC' stored in the CPo In exle"ded mod~, the full range of functions in accordance with the ASi master spc~ification is available. If you use the Fe bl""k suppl ied, maSter calls can he made fwm the user program in addiTion to standard mode (transfer of parameters during operal;on, checking of 1he desired! .~lUal configurati on, test and diagnoslics) , AS I slin'e. AS; ,lave, can be bu.-enabled ,ensors and aC mator. with ASi AS ICs, or they can he AS; modul ~s. You ~Onnecl ,ensors and actuators with AS; ASICs to a passive module. Convon tional sen,ors and actuators can be connected to an acti,'e module. ASi ., laves ar~ available in the standard ,'~rsion with One standard sla,'c oc~upying one of the maximum of ) I possible addresses. The user program handles the standard slaves lil:e h;nary input> 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.

ASi master Standard ASi masters can control up lD 31 standard ASi , lave, with a maximum cycle lime 01'5 ms. In the ca, e of extended ASi 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 3432 is used in an S7300 station or in an ET200M stalion. It supports tho foUowing ASi slavc-s:
c>

Standard slaves
Slav~"

""

wilh extendcd addre"ing mod . (AlB

slaves) "" Analog slaves to slave profile 7.3 or 7.4

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

Connecting PROFIBUS DP PROFIBUS PA

10

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<igned to the relevant DP master as a DP slave with a freely sckctable node address in each case. The maximum size of the transfer memory is 244 bytes of input data and 244 b;1CS of outp ut data, divisible into a maximum of 16 areas.lnp.,l areas in one ,ubnct must correspond to output areas in another. Up to 128 bytes can be tm,nsferred consi,lently, If the s ide w;th the input data fails, the correspond ing OUlpUt data on lhe other side is tnaintained at its la't value The DPIDP conpl~r is configured and parameterized with STEP 7. A GSD tile i, available for operation on non-S iemens masters.

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<rntcd at 45.45 kbitls. Up to 31 PA field de" ices can k connected to One DPIPA coupler. The field devices fonn a PRQFlB US PA segment with a data transfer rate of 31.25 kbilis All PROFlBUS PA segment. wgetlJcr fonn a .hared PROFIFHJS PA bus system. The DPIPA coup ler i. available in two veT<ions : a non_Ex version with up to 400 mA output curren! and"n Ex version with up to 100 mA OUlPUI current.

PN.'?N ""uple'

T fJPB
link

Serial <oM<Clio"
FiIlU~

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.. 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). 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> t>

link suppon, the procedures 3964R and free ASCII protocol. 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. 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. 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.

Standard .bves. AS-i aMlol! slaves Slaves with extended a<klre"sing mode (AlB slaves) Slaves with data transfer mechanIsms in accordance with AS_i spe<: ificalion V3 .0 (DP! AS-i Link Advanced)

t>

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

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. Conn .. cting PROFlNET 10 to the AS_Interface

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 .

I.J.! 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. 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 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 to

Introduction

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.

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.
Data is exchanged via a conn ection in aCcordance wilh a specifi c eXe<:U1ion plan Ccommunications ,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

Standard slaves. AS-i analog slaves Slaves with extended addressing mode (AlB slav~s ) Slaves with data mmsfer mechanisms in accordance with AS-i specification V3.0

p.

The IE/AS-i link is configurcd and parameterized with STEP 7. A GSDML file is avajiable for othcr configuring tools.

1 SIMATIC S7-300/400 Programmable Controller

51 MATIC 57 station System memory

51 MATIC 57 station CPU User program Connection ID System memory

CP Operating system

Received data

Communications function

Bus interface of the module 5ubnet Con'lec:.tiQD

Connection resources

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 . N etwork
A network is a connection between sev eral devices for the purpose of communication . It

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). Connection
A connection defines the communications rela-

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.

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.

36

1.3 Communicat ions


l\ fP 1

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

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

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,. PROFTBUS High -speed e"change of small and mid range volumes of data. used primarily with distributed 110. 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.

t>

t>

t>

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".

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,.

.,
Station_ internal 57 basic commun icati ons CP )42_3: PROfIDUS DP VO CP 433 _5 Ext.: PROFIBUS UP VI

H.,.dwarc conliguflItion,
SF BiS FC call.,

CP 443 - ~

~xl...,d.d

- --

FMS int'-TIace CPU, with

Industrial

PROFINET 10 (10 controller)

"
TCP/lP and C OP.

CP44.11

CP343-11T 57 cr 4431 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 cltrical 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 conntcd 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 .. to all conne<:ted dcvices. .ed

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 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. Siemens applies PROFlNl:T to two automation cOllcepts:
~

AS- I nt~rface

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_ 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 .

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_

A maSter ""nlrots up to 62 slaves thro ugh cycli c scann ing and w gmlmntee' " defined ""pense "me.

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 .

1.3.3

Communication s ServlcO/"S

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.

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 <HId PROFl/'>.'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

conlanee wi ,h RYC 793.1S0-<Jo-TCP in accor' .... nee with RFC 1006. ur UOP in accordance WI th RfC 768 . Th~ C(Jmmunication functions are luadablc runction h locks (fH~) containeo in the Smmh",J Ubra'Y of STt::!' 7 under Comm,, tliClllimr Block. The function blocks are c"lIed in the main program and they control eO'.mC'CItOn buildup ""d c1"ardown as ",ell a, <!ala transfer,
Glohal dara
communk,.tlon~

communicatIons

S7 \)asic eOmJl\oni<Hlion~ i~ an e,em-conlrollcd .oeMc" forexchanging ~mal1 volume, of oata he\v.ecn " CPU and a module in the same SIMATlC station ("statiouintemaJ"') or between a CPU and " m<..M.lule ,n a different S I'\1ATlC station rstalion-<:=xlemal"). The con nections are established dynnn>icaUy 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'" SfC. StatiOll.internal S7 basic communications is necuted ov~r PROI'I HUS, .lJItion-c:xt~m81 oyer '\1 PI.
S7 cn mmuuic"tion,

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 <lala communicarions is only poII~iblc ov~-r rhe MPI bu. or th" K bus.
PIP C(lmmllnicatioDS

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<fer procedurn. SS-i:(lmpatible
~omm"nICltl ... n.

S7 ~('mmunicati(m";' an cvenl ..controlled service for exchanging laracr v()lume, of data bc!We~n CPU modllles with c()!\trol and lIl<mi. toring funeti()n, . Th~ connections are .\.iuic. and ~rc programmed using ST EP 7. The commUnication. furn.-tiuru. required fO'l" S7 communieanons arc cuh~-r integl1l1led In Ih~ o~ ...tinll ~}'$Icm of ti>e 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.

fF: communlcatlon
WiLh "'Optn eommuruclttion via lndu5lrial Eth,,",cl (IE communicatiOn fO'l" shon). you tJ<tmfer data b<.-tween tv."\) devices connC'Cted to the Ethernel SlIhnel. Communication can be implemented using the protocols Tel' nativc in 8C-

S!.compaliblc C<Jrnmun ications is an eveplconlrQll ed se,""ie,," for dUh' tr"nsfer tx.--tw","n SI\.1 ATIC "ations and non.SIMATlC station., The connections are shuie, Ind areprogratnntCO tHing STEP 7. The C(Jmmuo ications functions are usu~lly load"blc functioD5 FC with wbich you can control the transfer from the user pmIIl"rn. nata are ...,m aDd rccei""d OYcT the SlN"DIRECEIV E intcrfllce. and data can be fetched and written over thc rRTCllfWRl T [l int erfucc (S7 is a passive p"nner) . S5 -cQrnpatible ~ommunicati0n~ Cull be implcm~nted witb Industrial Ethernet usmg the Tel', ISO on TC I', lSO tl1lnsport and UOI' connectio,,~, and with PROrlBUS using FDL
Slanda r d co mmunk,.,loM

Standard communicatiuns n~l'$ standardized, wndor-indc~ndent protocol, for m<la transf.. .,..

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.
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.

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 Stl<rtup and remain throughout the entire program execution ("communications via configured connection~"). Several connecl ions caD t>e 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~

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

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

1.4 Module

A~

" HPOI . L _SIO ( ..

,~,

modulo

.,

0

,,Byten

., "'
.,

,
Byf1I
n~ I

~'

.,..

.
----

Process-image

. .".
11 -+

1234 56 7

-, ._.
r

start add", . .

~".

i:
U.", P
~ s_ c "

.""

.,...

",,",a

Abso"'t"

.... m (LAD)
on mo lor"

!"11m IFBDl USII' ~ S ... ;tc:h on motor"


,,~

15.2

II

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

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").

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 addressl. 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

I SIMATIC 57_3001400 Programmab le Controller

1.4,3

Logical Addu"

1.4.4

Module St art Add res.

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 <ignals (voltages. cur",nts) are referred to as "channels", each of\vhich requires two byte,. Derending on Iheir design, analog modules cmt with 2. 4. S or 16 channels wrt'Csponding to an address range of4.l;.16or32bytes.

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 ..

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

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").

assigned ac"ording to addrcsses in the process image so Ihat thcir .,i gnal <latuses are automatically updaled and they can be add"""ed u,ing the address area, "Input" and "Output". Analog modules . FM modules and CP modules are assigned an address which is nO! w ithin the process un age.

1.4.6 MI'I

i\dd...,sscs ror

Ru~

"odes

I>

Ibe L Stack. (sec Chapler III.I.S " Temporary Local Data")

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 1 comrollcr (thc ,n ter0 fdce) 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).

To this are added the code an d data bloch with the block.local variabl e~, depending Oil the user program.
1.5.1
addrcs~

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. \\'hen modules are access~"<J. iI makes no diff""TenCe wh"ther they are in 11I~k.s with centralized configuration o r uS<."<:I as distributed YO. All modules occupy the ~me (logical) add~s space.
A module's user data propcTtie! depend on the module type. In the case o f sill nal modules. they nrc either digital or Bnalog input/output ~igllll l s. and in th~ ~HSC offu nctio n modules and COllununications processoN>. 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 <tan address: it i~ 5tipu lated in the coofiauration table.

'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


!>
I;>

the peripberal inpulS and outpul'o Ihe process input image and the process out_ put image Ibe bit memory area 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 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.
acce$~

!>
I>

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 ur<ioted at The beginning of T program ,caD. he Peripheral inputs may oceupy the saf"e ab,,," lute addre>ses a, peripheral outputs .

additional memory area sitnilarto the bit m=OIy area. Thi, appl ies both for the process input image and the process OUtpUT image.

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 .

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

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 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 r<feT 00 Charter 20.2. 1 "Proce>s lmag: Updating" for more details. On the S73UO 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

,. 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.

advantage, arc offset by an increased progwm re'pome time (please also refer to Chapto: 20 .2.4 '"Re;;ponsc Time").

"Ib~,;e

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:
~

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<fer area for an intellig~n t DP slave i, di" ided into several consistent blocks. Data cons istency with internode communication is the same as with direct a~~CSS (I -, 2- and 4- byte consistency). This similarly appli es to data transfer between 10 controller and 10 devic es on Ihe PROFTNF.T 10. When configuring stations of the distribut~-d VO w ith three or more than four bytes of user data, you Can specify th e con.istent user data "reas. T hese areas are tran, ferred consistent 10 the parameteri~ed target area (e.g. data area in wo rk memory or proc ess image) u,ing the system functions SFC 14 DPRJ} DAT and SFC 15 DPWR DII.T. P lease note that the "normal" updating of proc ess image. can be interrupt.. d folluwing each transmi tted doubleword. An exception wilh newcr CPUs is tile ,ransfer of user data blocks for dimibUled 110 using a partia l procc~. image if the u s", data b locks can be configured as consi"ent using the hardware configuration . You can also influence th~sc data blo.:;ks in the process image using a direc t access. but you could also possibly d~"roy the data consistency. C PU-specific data apply to the maximum size ofa consistent ar.. a for data transfer with global data communications. S7 ba s ic communication, and S7 comnmnications through thc op"rming system (s~e Tcchnical spec ification< in the C PU man llal). D iagno"ic. data and parameters are always transferred consi ~tell1ly in data records (e .g. d,agnosucs data ",nh the SfC 13 DPM RM DG or SFH 54 RALRM. or parameter data tran.ferre..! \0 and from m odules w ilh the SFB 52 RDREC and SfB 53 WRREC) .

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.

I SIMATTC S7-300/400 Programmable Controller

1.5.4

Bit Memories

CPU i~ parameterized. Please rer.,- to Chapter 21,1.4 "Retentivity" for additional infonnation.
Clock
m~m .. rics

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

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-tospac~ 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 cxution of the main program Clock memory byte

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. 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

17 1 6 1 5

j41 3 1z l tlol

5 Hz (fllcke<lng light) 2.5 Hz (fast ~as hi ng light)


,",

I 10H~

0.625 Hz (slow flash ing light) 0.5 Hz


F lgur~

, "'

, ,25 Hz (nuh ing light)

1.1n Contents of the Clo<k MclYl{lty Byte

2 STEP 7 Programming Software

STEP 7 Programming Software

2.1

STEP 7 Basis Package

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<Jjcct data. The memory requirements may increase for cenain operations. such as copyi ng a pmjed.ifthere is in.uffic ie nt space for the 'wap-ou.] file, eIT<JI" such 'IS program crash.s may occur, You are recommended not to Slore th e proje~t uala on the drive containing the Wind<Jws s wap_out fi le. The SETUP program on the CD is used for instaUation, Of STEP 7 is already factoryinStalled on the programmi ng device , In addilion to STEP 7, the CD also includes, in/a alia, tb e AUl<Jmation L icense Manager (see Chapter 2. 1.2 "Automalion license Manager") and lhe STEP 7 electron ic manuals with Acrobat Reader. A n MI'l interface is needed for tho <Jn line eonnceti<Jn t<J a programmable c ontroller. The programm ing dellkes have the multipoint inter_ face already bui lt in. but rc, musl be "'trofined witb an M1'I modu le. If you want to usc I'C memory cards OT micro memory cards , you will n eed a pronuner. 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~<Jusly from several workstation . You make the necessary scllings in tbe Windows Control .Pan el with th~ "SL"-1ATIC Workstation" program. In tbe dial<Jg 00,.. that appears, you can parameterize the w"rkstat;on as a s ingle_u.er system Or a multi mer system witb the protocols used, 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.

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 <JC high~T is requi",d under all op"rating 'ystems You require administrator privileges in order to in'tall STEP 7, and yo" m"st be registered at least as a main "ser in order to work with STEP 7. Ify<JU wish to w ork rapidly with STEP 7 or pm_ Cess large projects. e .g , w ith sev~ral hundred modu le s, you should uSe a pmgrarruning dCllke or PC with up_to_date ptoeessing power. STEP 7 V5.4 <Jceupies approximately 650 I<J 900 Mfl ou the hard disk depending 011 the ,e<Jpc of installat ion and the number of installed languages . A swap_out fi le is 81.0 needed.

2 STEP 7 Programming Softw=

2.1.2

Autum.llon LIcense Manager

2.1.3

SII\-IATIC M.nager
III

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.

The SIMAflC Manager is the main 1001 STEP 7: you will find its icon in Windows ,

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",<uired. via the menu command Ftu; ~ "NEW PROJECT" WIZARD Programming begins wilh opening or creating a "project". The example projects supplied are a good ba> 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-

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.

(>

(>

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< as thc object Blocks, which conlch tains, among othcr things. the compi led blocks. The STEP 7 object' are connected to one another v ia a tree structure. Figure 2.2 shows the most important parts of the tree slIUcrure (the "main branch'". a. it were) when you are working with the STEP 7 basic package for S7

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

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.

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

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.

2 STEP 7 PruWummins Software

Con, aine, fo, aU dabl of. programmable conlrolier

MPI P I P PROFI8US,
Industrial EthlImet

Sub""'t

e",,,,,jo< tlle ne,wQrk pamm01C,",

"'tting f",. ,ul",,"


(fiu\"'ionan,;e~

"n,.,; k software)

Cont.l"or for.U d ota of

fl,. SI.\lATIC 3001400 slatlon


,m.,,,,,, ""d the p.mmel"" t?r
mooules
. ,,~

Confogura tk><> table

C<><\Iains \he "'{)n!igumtlon <Iota lOt the


,~.

Con<ol"", for tI,c ,0,,",co<lo," '.bl_ Connectloos

lb. u r prugr.m

OmUli", the dc!i nition. of <1'<' >rnmun i <.,;on. wnno<;' ions , he''''''''''' DOd., in a network

Cootaimr for aU dato of the "5Or p"'gr.m

Symbol table

Con", i"" the of'rm""l, (- n.me,) to the ab""luio addI ....,s of ;;lobol dat.
pro~r.m

""'!If\IDC"'' '

Co"'.in~r

for tbe

.onrco.
C"",.i~ 'he S<>un;" for \he mer program (~., for STl ailtl SeL progra,ns)
pJ'()~ram

Source programs

Contain.. for the compiled

and

. o nll~nratio n

User program: OrgantzaliOrJ bfocI<s


FUl'ICtion blocks FUl'ICliC'(ls Data bk>cl<$

Cont.in 'h comrilO<! <00< ."d 11K ohta

Data types

th~

('on ... i" 'he d.!1"jti<m, Qf u,e::- d.>ta l)'pe"


C"","i~

System lurlctlnns System functlons blocks System data blocks Variable table$

' be ~.Il intorf""" for blocks ,n\egtllled in tho Cl'l)

t~e

$y,te>n

Contain the """'piled daut roc tho configurntioo Ubie Co"tain the vari.ble, foc rrwWt(>o";'\j1
2nd modif0nlr

not ."'Iln." to any h.rdw ....

",ilh ,h. """'e ltrue"'" as

'0 hard,,=c
F igure Z,Z Object Hiera",hy in a STEP i Project

an S7 progrom ,hat i, '",igm>.1

(The undcriinMt objects arc on ly ptesent in the omine data llllOnagemenL)

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

and lib ra ries


t>

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<xts (see Chapler 2.1.5 Mulliprojects').

Contains loadable functions for editing variables of Ihe eomple~ data types PATE_ AND_TL\l Bnd STRING Communication Blocks Conta ins loadable functions for controllin g CI' mo<lules 'ii.celianffiUS Block< C.IIntains block!; for time SUtmping and time synchronization Cont.ltlns loadablc function clOS<.'d -loop centrol
t>

1>

I'roJecu are used for the ~y~teftUl.lic storing of dilla and programs needed for solving an automalion task. E5Sentially, these arc
I> I> I>

> PID Control Blocks


block!; for

Ihe halth"are configuratioo data. Ihe parameterization dala for the modules. the configuring dala for communicatiot\ via networks, the programs (code and data. symbols. souKes).

t>

OrganJ~ation Block, Contains the templatcs feT the organization block. (es<enlially the variable declarotion for the stan in formation)

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<e objC<::ts.
Ll/)rar/e.f an: used for storing reusable progrnm

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:
(>

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~ 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. 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

System f unction Blocks Contains tho: call inl~-rf.c<:s of thc .ystem blocks for offline pro8fllmming integrated m the C[,U S5-S7 Convening Blocks Contain.,; loadabl~ functiom fo, the S51S7 convertcr (replacement of S5 standard fune_

I>

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.

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.

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

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_

2.2

E d i ting Projects

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.

\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.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<ot the top ics you need infonnation on by <~lecrin g the HELl' menu, The online help option OETT ING START ED , for instance, provides a brid summary on how to use the S IMATIC Manager.
H EL P ---> CO:-'OEN TS ,tarts the central STE P 7

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...

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 Edilinll J>roje<:ls You


~Iart

Ibe

proj~1

wi zard using fILE .....

''''cw plI.orrcr WIZNW.


CrT.Unlt a
s~clion
proj~et

the hanlwa~ configuration. the open station no" al$O shows the CPU .
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.

"ilh th e 57 stllll"n

If you ,,'anI 10 ~r~ale a project "",an<lally'. Ihis OUllincs tbe nessary ICI;ons for you. You will find general infonnalion on oper.lIor enlri~ for objCCl edillng in Chaplet 2.1.3 "SIMATIC Managd' . 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 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
S~ICCI

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.

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 eelicking 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<:~'<Iun:: descrilxd above. drag and drop them in thc appropriatc $IOts. To enable funbcT OOllinl of tile proje<;l Strw;ture. a 5tation requires at le35t one CPU, for instance t h~ CPU 314 in slot 1. You can Rdd al1 othcr modules later. Editing of lbe hardware configuration i8 di,;cussed ;n <iel8il i" Ch~pter 2.3 -Conllguring Slations".
SIO~ and compile the station. th= clo", and rerum to Ihe SlMAT1 C Manager. In addition 10

\\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 objCi container 5oll":"" is empty. With Snurc~ selected , you can ~elecl I'<SIlII.T ..... 57 SOI'T\\AItE ..... STL SOLlI.CI! IU irl,ert an empty .0\lfCC text file or you CIlD select lNS(Jt T ----> E.'Cl FR'iAL SouRCE to 1JltlI.rer a source leKt file created, <ay, with another editor in ASCII format \0 the 5olirce< container. Crutlng. proJeCI without pn S7 ftlllon If you wish. yoo can create a program witbou\ first having 10 confillu~ a station. To do 50, generate the cont ainer for your provarn your-

2 STF.P 7 PruIlTII.mmin, Soft",'.", 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
~I[

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 ..... RI1UEVE 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

J\lanwglnll' An:bJvlnS(

~t'()IIIYnl/.lnw

and

The SIMATIC MRnager

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"ojcs 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

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

'l<>Ie " project in archived (comp ..... . ed) form in

Tfyou ,,"ant 10 fetch back thc projcctda ... SIOred


on Ihe CPU without ereatinK a projecl on the

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

hard d isk, <ekel the n:lcvam CPU with PLC .... DISPLAY A=SS!9lE NODi'S . If the memory canl i, plugged imo the module rttt..-ptacle of the pro wamming device . .-.c lcct tb" memory card wilh Fn.[ ..... S7 Mf.MORY CARD ..... OPIlN before tran.ferring.

2.2 Editing Pmjo:<:l$


2.2.3 Proj eCf Version s 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

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 it into a """,ion 2 projett with F1L -+ OI'D> 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<miiauralion remain unchanged.

-+ 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
you <elect
~Muhiproj....,f'

Os the t)'1X' in the dia.

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 .

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 pmSII 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
into the mUhiprojccl.

"

2 STEP 7 I'rogrammini:C Software


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.

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<ln$ you in the matching of CTO""proj ect CO r1ll eClions and when comb ining s"bnets (Chapler 2.4 .6 'M alching Pr"j CC15 in a M ulliproject"). You can identifY One "fth;: libraries in u multiprojcct as the "ma.lter dala library' \Ising FlU: -+ MUl1U'ROJ~l"T -+ DF.rn-"EASMASTHt DATA 1 .IlIRARY. Tbi:i contains., fot example, the commoo blockll of the pmjects in this mul[iproj"t. This libnory must th~n only tOlltain one singJ;:
S7pro~.

STATION --> SAVE o\l'o"D CO~II'Iu! I\Ot only saves hut al<o compi le [he oonfiguratiOn tables and store~ thc ~ompikd data in the $y.'u,m dma object ill the ottline conta iner 8/(>ck.<, 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 uport 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 ch~lcl;um 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
obj~(.

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 1 the CPU. You can also use th is 0 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.

The checksum i. a property of the S,"SIcm daln To read the ch~"<:ksllm. Opel'lthe Blocks

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

Whrm configuring has berm completed, ST .... nON -+ CONSJSTer-'t"Y CHECK will show you

2.3 Confil/Uring Stations

Hi" ....

l.~

Example of. Sta';<ln Window in the Hanh, ..... ConfiI\Jra,ion InSlalllnl b udwan <lpd.tn
\\1m Omo'~ -+ ISS'fAll II W UPDA"ffiS you con update components for the hanlwan: callllog. In the followinJl: dialog.~. Klcct whether }Oll wish to download the update from the Internet or copy it from a CD , Enter the Tntemct address 8nd the save path , By clicking the Inslall" bunon, the Hardware Confi gurntion transfers me data into the hardwan: catalog.

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.
H a rdWlI rt u tal"g

Product SU ppOM inform ation


TlON

You can faue the hardware catalog in and out with VllW ----jo CATA1.OO. 11 conta ins all avail_ able mO<lnting rach, modules and intm"ce ~uhmodulcs known 10 STEP 7. With OPTIU~S -+ EDIT CATALOG PRO~tlE, you CKn compile your ow'o hardware catalog that sllows only the modules you waDI to ",or\< wilh - in the stJUC:tun: you select. Ry double-clicking on the lille bar, you can "dock" the hardware catalog onto the right edge of the station window or release it again,

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. 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 )'<IU deselect the option ~Sysu:m default" in \his lab for S1-300 modules. you can ehanKe the module liddTCllscs. When dning so, pl.,ase ob$crve the add\"C!lsing rules for S7-300 ami S7-400 syStems as well as the addressing capacity of the indi~idua\ mod~Addn::s>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 rei"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).

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 .. bornes 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.

The llmonscment of distributed 1,0 stations is ckseribed in Chapter 20.4 "Communication ~ia Distributed 110".

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 &Iolute address" without symbols. The MApply" bu!ton trans fers the .ymools inlO the Symbol Tablc . "OK"' also closes the dialo& box.

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

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-

their MPI addtnscs. If you do nol want to assiJl11 a name yourself. you can, for <o~ample, ebange the d~faul( identifier from ''CPU :ux(l)"" 10 "C PU:ux(n)" where "n" is equ"lto the MP! address When uliigning the MI'l address. please also take inlo accounl me possibility of connecting a programminll device or openttor panel (O r) to the MPI n"""oB at a later date for seTvice or mainteMn~c put"f'OSCs. You ~hould connect pcrmanently iru;talled prollrnnuninll devices or OPs direCT 10 the MI'l networK; for plugi n dC"icn via a spur line. there is an M P! connector with a heavygaullc threaded-joint soekeL Tip: reser.. c addTess 0 for a scrvicc prognmtming dcvice, address I for a serviee 01' and address 2 for a replacement CPU (COTTespo nd. to the dcfault addr~S5eli).

,= .

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").

!.3.~

i\l c mitorinlil and Modifying

l\tudul~

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<o se veral stal;ons with the same !ypC of CPUs. assign different names (identifi e.... ) to Ille crus in the d,iferem ,talions. They aU ban Ihe name ~CPU:ux( I )~ as default iIO in the subnel they can only be differentialcd by

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".

"

2 STEP 1

Pro~1IlIIlinB

Software

2.4
The

Confil:urlng Ihe :'Iiet".-ork


ba~it

ror ~onununicalion, ,,';!h S1MAT1C is the nc:tw9r1<ina of t~ 57 stiuions, The Il'qui~ objccts are the subnets and the modules with communications capability in the sta(ions. You can create new subnc15 and stalionJ

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.

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 bnwo 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:
f>

In the upper section, the NetwoO: Con figun.. tlon window shows all previously Cfated ~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(doubledick 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,

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).
Use the :-"elwo"" Configuration 1001 to C~ ate the necessary . talions and - if required funher sl.lbnets. Open the station. and provide them with Ihe modules with commun icalion! capability. Connect the modules with the relevanl subnelS.
Adapt the ne\Work parame1C1"!1. if DeIBry.

c>

po po

2.4.1

Configuring th e ,,",f two rk lind


arran glnlllh~

VI~w

StI~cIIO I:

(omponentl

I>

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").

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-

.,
lor ... .. .,. m ",-

,-

r:=0i-:. i ;;;;;;'
.....
. .J _

- '" ..... . ... ...... -0

...-

-\""

.. . . .............
-';;' ''. ._ 1

..l _~ "

. "' ."

......

. . .1 -""''''' . >'0 J _

" :::11'_ " --''' ...1<'_ -, -",,,,,,,

>-

is=-

--

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_

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

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

-.

represemcd as ... ,erticall ine.


p~

in exactly the s.ame way wilh aU other

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<k. you Can define the network. propcnies o f the node "';Ih EDIT ..... OI!JEC"T PROPI:RTIES. e,g. , Ihe node address MId the subnet it is connected to. Dr YOII can create a new SlIhnc!. On Ihe "lnll:-rlaces" tab o f lhc station propcnies, you can sec an overview of all modules with

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<l subnet lenaths with VIEW .....
REDUCW SU II:'>"ET tl:.....Gnts.

2 STEP 7 prognomming Softw.,.., 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. 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~..... I-'ROHNl:T 10 In order to configure a PROF INET 10 ~YMcm. yuu reqUIre :
I>

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 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 1 devicC"S in the neN"Ork view. 0

PROF'IBUS OP
You require the follow,ng in ullier to configure a OP maRter ~y.tem :
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>

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 .'II~t lID 10 controller with Ihe Hardware ConCigurnlion 1001. either intcgrated in the CPl: or liS nn autonomous module) 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

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). 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.<ter in rhe Network ContigUflltion, "hold" nnd drng to the PROFm"L-S nClv.ork).

I>

The:

<;OfIn~"Ction

I>

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).

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 mod/ ules (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.

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'TlMT F COLlJM"I 7 WIDTII and VIEW ---> DISPLAY COl=S and select the information you arc interested in. ConnectIon
[l)

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

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 doubleclick on Connections starts the Nem'ork Configura-

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,-

Tabt e 2.1 Conneclion Table Example


P~rtners

2 STEP 7 progralDming Sofu... rc

Ii

j ,

"""'~ I

,1
,co< "".

L>o4~f"'_ ~--~~

r
r
;C'

,,,,,,p,,-,
l_",toI

f -

I'
Sont _ _ _ _
~~~

""";11

,,

r,-'",-rawo;;:."

..

.r

~ '~obI"'~~_

~d

TI :
'I

,I

I
3
1

1 1
- -- --

-~
~

t"iRu 2.6 ConfL guriog CommWlicatioru Connoclioru

.. IJ

.ary if you have a lready programmed commu n icali on < blocks and you want to u<e lhe local [D ,;pecified there for the ~onnection You enter the new local 10 as a hexadecimal number. it must be within the following value ranges, depending on (he connection type . nd m ust not already be assigned,
t>

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-

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 Valuc range for PIP connection>: 10rxlt,., to 1400 he ,

f>

"m

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) .

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.

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<ic is to send il5 operaling stal~ m~<;;ages. aClivate the ,levanl ehc:ck bo", in me propenics wiodow oflhe cOMeclion. In the uSCr program of me panncr C PU. Ihese messalil"s can be receIVed wilh SFB 23 USTA-

TUS.
Con ne ctio n pa lh
As th~ connecl;on palh hc propenie~ window

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 betwn 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

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.

ofm~

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.

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).

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)

ASSIGN PG/PC. This aJarlS the interfaces of the programming device to the conftgured set1ing thc tings for the subne!. Before disconne c programm ing device again from the subncl, select PLC --. CA"S"CEL l'G/PC AsslU~"

I> I>

Programmi ng devices/PC. 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)

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 <uhnel 10 in thc nctwoTk conftgura_ tion by ,electing the <uhncr an d thcn EDIT ---> OIlJECT PROPERTIES on I he "Gencra1" tah.

1.4.5

Loading th~ Connection Data

2.4.4

G8tew.y~

If the programmmg dcvi~c is ~onnected 10 a

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 selted. you ~an ~hoosc between the following ---> SIoLIClloU STATIONS

<ubnet. it can reach all othcr nlxlos on this subnet. t"or example, [rom one connection poinl, you can progmm and debug all S7 stations ~on nectcd 10 an MJ'I ncnvork If anoth~r subncI such as a PROFIBUS subnet is connected 10 an S7 station, thc programm ing d~vicc can also rea<:h thc Slations on the other subnet . The requiremcnt fm thi, is tha t the station with the subnct trans ition h as routing capab ility. th at is, it will channel the transf~m.:d message frame.. When the network configuralion is compiled, routing tables containing all the necessary in fornmtion arc automat ically gcncrat~d for the stations with .uhnel lransitions . Al l acc ess ih le cOlIUllunications partner< mmt ~ configured in a piant n~lwork wilhin an S7 rmjecl and must ~ supplied with th~ "knowledge" of wh ich .tatioru; can bcrcached via which suhnets an d subnel transilions.

---> --->

SELIoCTED AND PART'<ER STA TIONS S TATIONS 01\- TI lE SUH" "ET

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 --.

--. 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<ociated module. TI, e compiled connection data ar~ also a component part of the System d<Jla in th~ Blocks contain~L Transfer of Ihe systcm dala and the subsequem slartup of the CPUs clTcctively al<o

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.

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. Sckcting VIEW ----t CROSS-PROJECT NETWOR K VIEW " g a in exits the multi proj ect vicw.

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-

... ::!iiI'"'" """"-, , ...., l:..bo<b =~ 0'0 '-"'-' '; if ~"" - c_"
t""", ...... ,,_~""

:..:l'""'""'''''' """'" ... _ , .- ,",,-,, '""I "' . ,......""a" ....""


'"~tAO

'"

,,", eo~

L _'..M_""" "",-, _
cv..... ""'~".

c.""",,,, ,..."-"",,

8'""""""""_

,i '''---'''' .. '"
!fu. _ _
{_

II CP>J"<C-lQr' '; III s,.... 'OC3X(.l) SC ""'"' ~A" '_OC""

,I M_
~

tw ,,,e, Of'

"It:m:\)

.r-.

1" __

F ig u c. 2. 7 Mu l1 iproje<ot in the Network Con fig uration tooJ

3 -1
I

...:.~.J. __ t,

2 STEP 7 PToiramming Software Com bining


5 uhne t~

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; ~ MUU1 PROJECT ~ 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
~

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<Jictions with N ETW'ORK ~ CHEC K CROSS-pII.OJl:cr (:O;';SISTK'!CV.

...

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<.. sub""l. '1 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<J by a different symbol in the SIMATIC Manager. C o n,bln lng
~unn~~tlon .

2.S
2.5.1

C r ealing th e S 7 P rogram
IntrOdu ctin n

The connC<'tions configurt"<J in slOal", proj~cts which lead to a partner in another proj1 ean be combined 10 a muiliprojccl. If you select the pann~r "In unknown project"" when configuring conneclionl in II smgl'" proje~t in Ihe win_ do ..... "Insert new conn""'ti",," . you can subsequently enter a conneclion nam", (reference) in the window "Propenies - S7 connection". Con_ nections in diffen:nt projO"Cts with the same connO"Clioo names CIUl be comhined autom,,,i. cally_ In Ihe SIMATI C MBltagcr, Ibis is cMmed out by the w izard for project malch ing if you cl ick "Combine connO"Ctions" and E~ecule. Connections a~ Ihen combined which have identi cal connO"Ction names (reference). In the Ne","-ork Configuration 1001. you ean also combine conne<:lion' willt "unspecified" part_

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<Ifi'.l" and BloclcJ (Figure 2.8) .

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<lssibl~ in all the balIie languagC"'l. In tnc caSC of sou" ~ .... ri cnfcd pro&fBlll ere ulion. you wme one or mor~ prolP"lUJl sooree" a nd store these in the container Suurces . Progmtn ,o ...rees are ASC U text tiles that contain Inc program .lat~mcnts for on~ oT more bloch, po~sibly eVCD for the emire program . Yoo compile these sources and you gCi the compiled blockll in the contai ...... Blocks. SOUrce-ori(111ed prugnltn creation is used in STL and SCL: you cannot use soun:c-ori(11led PTOlPl'mming wi,h LAD or f 13 D. but programs created with LAD OT fB I) can ~ stored as KlUree l11es. T ho .~i gnal Slatcs or th e values of nddresses arc I'roc:..o:t.~d '" th~ ~t()~a",. i\n ~~.. ,~. ,<:>' e:<ampl<:, the input 11.0 (ab,wluw "'Jdrcsy;ng). Wilh the help of the Syn.bo l T. b k under the object Symbols. you can alisip a symbol (an alphanumeric name. e.g. "Swilch motor on") to an ISddrc$S and then access it wilh this nam., ("y",bollc addT"C.Jsing). In Ih~ properties of th~ omine ohjcct container Bladt_f. you .<l"'C"ity whether in the event of a chanac in the Symbol Tu blc the absolute addre~~ or the ~ymbol is to be defioitive for the already compi led blocks when next s.. >'oo (address priority) ,

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<kJn,,;ses and objeclS:
po

lnplns I, OUtpUIS Q, pcnpheral inpulll PI and pcriphCT1l1 outpulS PQ

to to to
;>

Memory hits M. t,mef funclio"" T and coumer functions C Code blocks OU~, FBs. FCs. SfCs. SFTh and dam blocks DBs User data types UDn Vanable table VAT

DaT addresses in the data blocks are included a 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 ProflUll, 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 <l ilion of a symbol. II defines 'pific propcnie! of Ihe d ata ~hind the symbol. essc",i~JI)' the represenlat;o n of the dala con!ent~. For example, the darn Type BOOL identifies. bmary ~'ariab\c and the dat. type Th;, designates a digital variable who~ COntents represent ~ l6-bit imeger. Please R!f~'1" to Cbapter 3.S "Variable.., Constants lind Data Types". it comains a detailed deS(ripl ion o f the data Iypes,

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_

"

2 ST IiJ> 1 J>rogrammi.ng Soil ...."""

" " " " "

, ", ..
" , , "
0 0 ; 0 0 0

"N "N 0

" " " " ""

.,,
'.J
' .1

" " ., " ,


~,

" " "

"

EOII'

0, ....,,, on ~ "",,,0,, ." .. """'''l' ... ". po~',," , .". , t 1ft ."" .. E.JIO """''!Y '"' '" "" ... " .o ," ~ .. ''''''or ,! ~, .. '"JO d "",,,", ,, .o, .... '"II' "'""1."1 ..
~'''' """""" .. Io, PO_

' dol' . 0 -So..


,_,od

... ....,,.., .... """'''''1[


;

"" ....,.""l

'00. r.. " ....... ,at .,...",


... , ' ...

II.-

~ ..

'...- ..

La ....... " " ".... t ..

~ ~
~
~

""0- , ... """ ... ... """,... "'" 1 boO! mo'" 2 ,.." '"" ,.,.,..,.,. "",
C. "...., .... "'''' '0' "",., ...

.....".<t_.'
N....... .,1 .. "

R...... ,.10 '''''' ....

Swc<. c. bel" """,arlo; ""'.,......, .

.. n

;W"''' ''' """ ... '0< ""''''J'' .,"

With incremental programming. you ~f~ale the 1<)'mbol lable b~fo", .,m.,ring th~ prugrum; you call D ,dd or COlT<:<:t individual symbols dur IS!) 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.

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<c "tuibutes Or properties are u.cd 'n the follnwing:

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<l Data Interchange Format (,dif tOr Mi<--rosoft Excel). You can edit m e exportw file with a suitable editor_ Yuu~..n " Iso impurt a s),n bol table available in oDe of the fOmlb\S named above.

I>

Httman mach in ~ inlerface monitoring wilh WinCe


Configuring-me"agc~

fuTlclion~

for

I>

po

Configuring commun;ClI.ti<>TI~ NCM software

usin.:

lhe

po

Control al contact ",-ith inputs aDd bit memori~s in the program ed,tOr

\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~.

72

1.5.3

r ......gnun

t ltor ~d

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

iO<,.....,lJ1ental programming; however, you can enter new symbo ls or change symbols during pn>!lnlm input.

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 Import "x,-mal SOuroo

O1fttne

" r ----""'''''".':)

."'

..

~
InBlocI<s the PO

programming

Ontlne

L__

'~!.=~) ::o:

BlodCs

FI~ur~

1.10 Writing rftlirorn! " t!h the I-A[)fHl[) Ed",.>,.

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.

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". 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.

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~neratl and di .... played. ~...,h liS the ~"T<:ation langullge. pres<:lcction for commeots, aod symbols. 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).

The Details window can be displayed or sup' pressed usmg VIEw --> D t:.TA.lLS. It contains Ihe follo,,';ng \.abs:
Do

I: error ConUIlm; the errol'S foun<l in the bloclt:bylhe pmgram c<litor, e.g. fol1owilli <;olnpilmioll. With OPTIONS - I (''uSTOMI7.1l in tbe "Sources" tab you can SCI whethe r warning. arc also \0 be displayed.

. . ..
'"'' ' ,

- .--. -- ._... ......


-.~.,

.-.... __ .. .- ~....,..
~

_-

Ft~urc

2.' I Furnp]. of e<i i(or window ..

2: Info Contains information on the currently .~electcd ad<lress. 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<erve the addre status. 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''). 6: Diaanoslies Cnntain~" list with lite exis''''iI moni.orinil functions for process dialilnOSlics using .he S7-?O[A G option , package. 7: Comparison Contains the re.ults of a previously implemenn:d block comparison (sec Chapler "Comparing blocks").

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. 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. With the menu conunbnd FILE -+ STUIili REA.!). Ot-.L L. in the program edilor. you can save a "T1leprotecle<l CDpy of the currently opened (arid saved) block in anOlher block cODIlliner. To edtl " block in the CPU. open Iltat block in the onlinc window. This I.... nsfen the block from Ihe C PU to the Proiramming device so Ihal II C$n be ediled. You Can wrile the edilcd block back 10 the CPU with PLC -> 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

I>

po

po

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

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:<ec;ute" button. you selcct. III the subsequenl dialog bo:<. the bloch fn)n1 ",hich you want to generate a program source file. With FILl! -+ GIlNfRATE SOURCE you can p ro duce ASCII source files from compiled blocks, First insert a Sow"es comaincr under the object S7 progmnt , Whcn generating the sou""c, 1 1t'S1 enter the stnrage location an,! the name of the source in the dispL ayed dialog box, ~nd subsequently SCICCllhe blocks. You can cxport SO~ files from the project by sdectina EOIT -+ ExPORT SoURCE in the SIMATIC Manager. You ca.o then fllnher pro cess these ASCII files with another tUt editor. for example. Source files can also be imported back into the Sow'Ces container witb I:o.:SCRT-+ EXn,IlNAL SOOKCI!. If you generate a source file from a blocklhat yOU have ~Teatcd wilh LAD or fl3D. you can generale a LAD or Fl3D block agkin from this sou",e file , You ~ompile the sou",c file by opening it in the SIMATIC Manager "'ilh II double.dick allll by then selecting Fit I> .... 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 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.<cs in individually compiled blocks or in the emire user flIViTaIlI. For example. you can replace input bilS I 0.0 10 I 0,7 with input bits I 16.0 to I 16.7. Permissible addrcsscs are inpulS, outputS, memory bits. timers and counters as well as functions fC. and function block!; FBs ,

76

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 bL ocks 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<.><lificd. Funher pOSsible meth<.>ds ",f rewiring are:
eo-

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
I 1. 1

'Lt mit _a~ttth_up'

'Limit_switCh_down"

In the program of an already compiled bl<:x: k, input I 1.0 i, """nned:


I 1 . 0 "LUnie_ _ itdo_up"

!lOW

Tflhe Il!isignments fQr inputs I 1.0 and I 1.1 are 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"

With compiled block.., Y"'u can also usc the Addren prioriry function. 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.

I>

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 <ymbol table . [n this way. all already programmed block can be "rewin:d" by changing 1he address "ssianmen!.

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 1 tbe 0 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

Pleaoe nme that this "rcwirina" does nm occur Ilutumatically bc<:all,<e the already compiled blocks confaio [he executable MC7 code of lbc Statements .... ith abwlute addresses. The "baoge is QnJy madc in the rele'"l1nt bl<.>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:

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<e offline n;fereoce dala ~ displayed e'C"II if tbe function is called m a block opened online. 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<k, lhe absolute addR"Ss, Ihe symbol (if any). the block in .....hich the addn-ss was used, how it wu used (read or write) and th~ posi_ tions of usc of the addre.s. Click On a ~ol umn header 10 sort the table by ~olumn comenl~.

Cross referencc~ po Assignment (Tnpul. Oulput, Bit Memory. Timers, Counle~) po Program structure po Unused symbol. I> AddresSd without symbols
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

Eon _ Go To -> LOCl<TION wilh the position marked or. double click On the position starts
the pTOifam editor and displays the addmr5 in the programmed enVlTOnment.

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 prob'lam. The list shows ilic ~ymbol, th e address. the <lata type. an d th e COnm1~"IIt [rom the s y"Il1bol table . Advantage: were the addre sses in the list inadver1ently fOIgonen when the p rogra m was being wriuen? Or are they perhaps superfluo us . and not real ly necded? Add,'esse s "I tho u l sy mbol Thi, list shows all the addresses u sed in the program to which no symbols were allo<: ated. The list iliows these a ddresses and how ollen they were us~d. Advantag e: were addresses u sed inadverte ntly (by a~cidcnt. or ~c a u,e of a typin g "rror)? 2.5 .7 Langua ;;: .. St'tti ng

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~

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

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 poit,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

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

This li,t shows all addresses which have symbol table allocations but wc.,-e not used in the

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 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<Jned tc~ts arc di<played in the flr.ll ~Ollllllll and yo\: can translate the te~l' in the second co lum", You ~an t<:tch tbe trans lated texts baek '" lhe project with Ol'lIONS ...,. MANA{",E MULTlLlNGliAL TEXTS ...,. TMJ'OKT. A log file provides information about the imponed te~t. and any error; that may have occurred. Please note that the name of the import fik m o" not b~ ehanged ' ince there is a direct relation between ,hi, and the text type. conto ined in the fi!~.

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 STI' 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<Jrt I1le" a .c.v tile that you can edh ",ilh Microsoft E~ecl, for example. You can elller the tran,lation for each texl. You ;mpon \h~ fin_ ished tran,lation table back into your proj ect , Now you can ,w itch belween the language" Yo" can do this with several1anguages 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, .

Sdecling and ddel;Jlg a language


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<Jned language again with O PTTONS ----> -"1ANAGl' MLIl.m.lNGUAl TEXIS --,> DELETE LANGUAGI'. 'fable 2.2
Tnt type, uf tho rran,1ated tens (se lection)

Exporting mId impmti,,!; /exls


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-

titl

itt

2.6 Online Mode

2.6

O nline Mnde

If "" prQj~ct has be~n . et up , you establish Ihe

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 .

~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<XIulc Status. Selecting the BIQCh object dtsplays tbe blocks in the CPU's "set" mem"ry. You Can then edit (modify. delete. insert) individual blO<.:ks. You can fetch back the ~y.(cm da t~ from a con nected CPU for the purpo~c of, say. cominuing 10 WoR: On th~ basis of the e~i~ting configu"" lion. without having the relcv"'" project in the proinunming device daUl !IllInaaernem 5)'8lCm. Cn:atc. new projeet in the SIMATIC :\1l1nager, .elCCl the projeet and then PLC -+ U I'LOAD S"rATlO __ TO Pc. After spe~ifying the desired CPt; in the dialog box Ihat Lhen appear><, 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<mfigure th" SIMATIC station. Lhat io. 10 sel C PU parame_ ICI"lI and address and paramelerize modules.

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!nt~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.

2.6.2

I'rottctl 0l:

th~ (;.~r

P rogra m

f'1"tK~ elion

lenl 3: rfl"3dl .. rite protec tion

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'<J~:rnm. for tho ..... who do not know the pas,word, ~(". can defi ne J p ....ll~tion levels. You set th. ~rr>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

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 protled "~th a pas'<Word, ),ou will be prompled to enter the pass"ord. Befon; ~ct'Ssmg a pro1~"Ct"" CP U, you can ~t..o enter ,he pII~~word via PlC --jo Aross RlGlITS ..... Snup. F irst, sdt th .. relevant CPU or lhe S7 program. Tn Ihe "Rr)[~T P ~5'WOrd. diulog 0011, you can sel"<'f the o~tion -Use p,u~wnrd b defa"lt for nil pro""" ",, modules" to gCI Deee~~ to /III modu l.. ~ ~mlCClcd with the ~m~ password.
I '''s~word "eee,s authorizatioll n:m uins ;n fOTCe u~ti l the lasl S7 a~~l i"al;On ha~ been t.. nni_

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 }{UKP 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.

'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

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

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).
~

PLC -+ DlA(j"uSTIC/S~lTl!<.Q
--jo H..... RDWARE DlAo:.;orncs (Ott Chapter 2 .7 . 1 "l)iagnOlling the Hard_

WII!"C"')
--jo

MOOULr; INFo\t.\(A not.!

At thi~ prutection level, the user proiO'IT! ~1ltI o nly he read, reganlle of Ihe position of the kcy lo>ek swilch.

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) 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 .~

-+ OrEIl.ATI:'G MODE
[), ~play of the eUlTl:D1 operallng mode (foc instance RUt>. o C STOP). mooific;aTion of the oP='ting mode

-+ 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

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
Area~ ).

1"rllMfcrrhl K bl".,k.
In the eil."" of a R.AJ>.t IODd memory. yol.\ can HI$O modIfY. delete o r reload indi vidual bL ocks in adduio" to =ferring Ihe entire program online.
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.

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 eomp<mcnl of the load m~mO\)' is I~e Cfl()u~ II) acoommodate the C<lmplCie IW'I" program and also the modified blocks. you can edit bloch ""ithoUllimilation. Iflhe user program i. sa,ed on II nll.5b. EPROM memory ""rd, you Can cdil the blocks asll)na as the RAM eom('>Onem 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 blocl<s online. nnd tbese hlock:l Mall! tbtti r ehl<ngClr e,cn fo llo"<IDg an 0........... 11 re~ct or non-buffered $witehing on. Dckted block. are then no longer e xi"ent. In Lm.,rmuental prollnlIIllIling mod~, )lvu ~Hn mooify bloch< independent of one another in th~ oillinc data management on the programming devioe and in tbe online data manugement on \~e CPU. However, [fonline MId omin~ uHla man-asconent divcrge, it may n:sol! in t~e ed,tM being unablc to di~play the additional informatio n of the omine database: !bese dina can thom be lusl (~ymboJje idenlifiers.ju.:np labcl~, ~om tn~'ltS. uwr dllllt lypcti). Blocks thaI have been modified online are I>e.<t stored oftline o n the hard disk to avoid dma iIl<.'Oll~i>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 memory-

This 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:<osnclS[;1"1l1'oG ..... MOPULIl Jl'."1'OR-

\.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 <!alii address p<.:r program corrcspond~ 10 a change to the aClual ,a.lue in the work memO\)' (Figure 2.13). You ean upload thc actual val ues gl'nCrlltCd in lhe ... ork memory from a programmed (loaded) data bluck into the offlinc d" ln management by opening thc dnta block On 1in~ ""d transferring it

2.6 Online Mode

If a spoci.1 .",n ".lue


.. "'" p"'f-rammod. !he del...... " is usN

""we

IMiaI value
When dnwnk"dWjj; '"
mrnl ... 1<>&4
lh~

rpu.

lhe .an v.luo f\, ' ","" f< "",~ from !he .>11]'''0 data manall"-

""""Dry.

!l_d . .
~
rl

mory

If ''''' do..

bluc~ _ ...-.r h...., UNlJ"Kl:.D zrrrib"",. !he ...... vahle is .....~ '"

WRIT .DDL -~ WW;O',".C~;;;;'m'o;;;;.;------- / ' i1 (

I '1 ' ' ' ; I

Who" tra"'f=;~8 til<

""I".e bIo<t ,,., rho omi ....


dar.~,

'.

"aj"" ;.

~"'...,. Tho >tart , . ,,,,, '"

""""

,.".,ao:rUaJ

rbo: ""'"

Initial vaIu ..

the ~ m<:m<><)' i, 1101' inn' .... <'Od by !lr..

:"~2l"~~..:'~~
... ilEAl) DRr _ SIT 5<

~[t..;.. .... ,

Adua/ ~ a lu"

'1"110: O\UI , ~tu. bt<;"",,,. 'he ""uol ,' atll~ in rho: work mo"w'~. The actual ,.~""
;"11>< ""I ... madiO..l by <hoc (1Jtt _",n.

..

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~.

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 ,

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

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 <i g nals an d v alucs, c.g. with thc h elp of s imula tor module, and evaluate Ihe infoffilat ion rel 11med b y your program. If Ihe CPU goes 10 the STOP state a, a r ~ su l l of an error. you can get sUPP<lf"\ in finding the cau,e of th~ error from the CP U information mnoug othcr th ings_ Extcnshe p rograms are debugged in sc~t io=. ff, for e xample, you only want to debug one h lock, load this block into the CPU and call it in OB I. t fOH 1 is organized is in s ueh a w ay Ihat the program can b e debugged sec tion hy 8cClion "'hOln beginning to e nd". y ou can select the bl ock s or program section;; for debugginl! by u sing ju m p fu nctions to s kip those calls or progI"" lII ,~~ tions thaI arc not to bc deb ugged , d W ith the S7 PLCSL\1 optiona l softwa re . yon can simulate a CPU on the p ro ..:nmuning device a nd so debug your program w ithout ad d itional hardw"rc_ 2. 7.1 D iagn os ing
t h~

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.
If the cause

H a rdwa "e

In the event of a r""It , yo" ean fetch the diagnostics informalinn nf th c fanlty modu les with

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

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.:. 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.

me

Caution. Y"u mus'


s'al~.1

etW'", '/lUi no dongerou.. Can ",sullfrom mmlifjj/lk mrl"b/e.. !

2.7.3
gr.tm~

,\lonllorinl: and

/ll o d lf~ ln l:

VarIab le.

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.<ocll'llCd data fOflT1alS. You can gmtra!e up 10 2SS variable u.bl~. (VAT 1 10 VAT 2SS) and ...,sign them names. Toc m.ax imum !ize of a ,ariable table is 1024 lines wilh up to 2~S characters (Figure 2.14).

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 .

FI Ku r" l.U Variable Tahl. Eumpl"

You can g~ncnll" a VAT oftline by $"le~linl:: Ihe US/,,-r 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.
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

\ 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.
VAaIABLI: ..... Al.11V... MODtFY VI\LL~ ttnn.sfen Ihe modifY values <lnly on<'e and IIIIIDCdiatcly. withom ~\,;ard to thc ~pcdfied trigger condi ,;uru;.

a u oulin e eon n ectiun

To operate a va ri able table th'" has been ~rcatcd otUine, switch ilouliue wilh PLC...., CONl<o1::CT To ........ online. Yuu must switch each individ_ WI.! VAT o n linc and you can clear down Ihe coonection "gain with PLC --} DlsaJ'>."NF.CI.

,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. 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

2 .7.4

Forci ng VwrlllbJ u

Wilh appropriately e<juippt:d crus. you can specify tixed value. for certain variable . 1bc uscr prol7"'ll can no lon,er change the,,", value. ("[ordng). Forcing is pe"n;~s;ble in any CP U openlling 'lat~ and i~ exenned imnledi .. lely.

Call1ton: yt1U must eTUurt! Ihul no dang~'TOu" ..fOft:.S can result from fOlrmg l"Oriuhl.,.,,!
The starting point fur forcing i< a "ariJ.bJc table (VAT). Create II VAT, cDtcr the addfa<c~ (0 be forc~d and establish II. conne~liun 10 the CPU. You can open a window containing the fOl\:" ,'ailles by sel ~cting VAltJ..'\DL[ ..... DlsPI .... y
FOR.ce V ... L1WS.

Lm:,;:c .

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!<es from the variable table to th" for.::e window or enter new add",,,ses. You foa'"C 'he e()nten1~ of a toree wind ow ,n II VAT with TABLE -+ SAVIi AS . The followina address area. ca n he provided with II fOTCe value :
t>

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<un1. An ~""mlred w rite acc~ss leave. the toreed componem of the address urrchanged. i.e. ~he wrice prutcction is DOl reVOked by ,lte ~ynchmni:allion crror. 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.
T hc inpor I in <be pr.....,,,,,,, imag.: belo"ging ro,. fOr<:~d peripheral input PI is not forced; it i~ not preas~i l>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.

Inputll (preens image) [S7-300 ami S7-4001 OutputS Q (proces5 image) [S7300 nnd S7-400] ,''''';phernl inputs PI [57-400] Peripheral outputs PQ [S7-400) Memory hi t ~ M )S7-400]

t>

t>

t>

:>

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!<eS.
While the foree function u. aclive, the foUo,," ina """liel:
t>

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.

'" 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 S7300. the uscr program Cnn ovelWrite the force val_ UC$. 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", ccmnrfcm 10 tit.. CPU! Yo" "m, only ddele olorr:ejvb w;th VA'ITARtE -+ STOP FOJi;C",,0.

When forcing peripheral outputs PQ. the c;"ted Output Q in the pf""'CS~ imag~ is not updaled and n<ll forced (fon:ing is only cITe<:the "cxternally" to 'he mooule oulpuL~). The outputS Q are rctained and can be overwritten; reading the outputs yields Ihc wri"~n vlllue (no, the forc~ value). If an output module is forccc.l and if Ibis module fails or is "'moved. it will recei,"e Ibe force value again immediately on ",connection. Thc Output modules OUtpUI tii!!na! STate "'Q'" or th~ substitute valu e with thc OD signa l (uisaltle

"so-

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.

tion to REST ART and deactivated again at the transition to RUN.

2 .7.6

Test and process operation

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.

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.

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" 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 . 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!. 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-

2.7.7

LADfFBO Progrum

St atu~

\\,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.

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 .
SeieClth e network you want to debug. Activate the Program Statl," function with DEBUG -.> _\1UNlTUR. '-low you ~an see the binary . ignal

'2 .7 Tcstin& Ihe Program

E . . .
......... .........
......... . ,......
" --"

"

..-...... .-......
. -- ~.

" --" "--'


>

....
.j

.,

".--0'

." . .. '.. ..
0

"._......

.,

.,.,'

" ' 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)<MENT with debug mode switched on (see chapler 2.7.6 "Test and pmcess ope-ration"). You requir<: thil sc ning if me block 10 be debogged ;s cu lled mOre Ihan once in your program. You can inil iute statl.,s record. ing eilher by specifying the caU pa th (deter n"ned from Ihe: reference dala or manually) or b y milki ng il dependem on Ihe opened data bloc:ks w~n calling the bloc:k 10 ~ debugged. [f you do not set the call env'ronment. you monilor the bloc:k when it is cailed for Ibc tirst time.

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 ... lOS NC contacts or a.dd~sses with "d 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.
2.7.11

_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 (1lInologica\ 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.

Monitoring and Modlfyln!: Addrcnes

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<cr and selC'Ct EOIT -+ OPE!" OBJECT. With STE P 7 V5.2 and later. you will be uked in the default sctting whether you wish to open the data bLock using the program editor or lISing the application Parameter assignment for data bLocks
M

Switch lhe data vicw on in the program editor using VIEW -+ DATA VIEW. and ...,lcct DEBI,O

92

2.7 Tdtina the Proj.rarn

-'.I

..--,.,..
......... v_.

,J

--. -. ,... -- . ---


,III

-"''-

, ,

"

3 SlMATIC S1 Program

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.

3.1. 1

P rollr am

l'roc.~ssj n lll\ftlhods

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.

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<I_priority prognun is the main pm~ which is proce~~cd cyclicall y hy the CPU. All other event, can interrupt Ihe main program al any I""mion. the CP U then execute, tl:e as",ciatcd interrupt .~rvi~e routine or errnr

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<llioru; for sigllal proce.~sing, through .. lIich a plant (process) is affect~d in accordance with Inc <icfined contmlt,"s!..

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<el rm.aY"Tite. Before Ihe CPU begin. procH,;ng IN: ",ain progrdm, it ~xecutcs a .tarrup rom;Tle. Tlli< routine Can be trigg.red by .wiTching On tile !llni,,~ power. by actuating the mode ~w itch illl the CPU's front punel. or vi~ the programm ing device. Prognm p,uce..iug following exu_ lion nf the Slartup routine .lWDYS slart! al Ihe heginnina: of the main prullfUm in the case of a cold resrart or wann restan; in S1-1-OO S)'lIem . it is abo pnssiblc tu resume the program Kan at the point al ",hich it was inu:nupted (hOI
reslart).

-.

hand ling routine and rer~n\s 10 the muin pm-

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<sed (end of program). the CPU r(turns to the oper-

Pow. on

1
0

L /

I
""""m
SI~nup

I C,.. I I

~ ~
M al ...

<lnletTUpt>-

'""""'"
p ro_ in(ellupl

I
IntorrupturoAee

~
~

~-

I
Error ha ndllnq
routine

<Faull>

g,am

OperaUng

,
.~"'m

)
,

FIlM .. 3. 1 Mnhod. or Prnct.-.<ing the U-= PToi<"J"

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.. timcof-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:-<i o'llanizalion blocks are CPU-specific; nol every C PU clUl handle all possib le STEP 7 ,,"enl'!.
J. I .2 P r] " r lly
Cla.~lfl

asynchronou. errors.
An asynchronous error is an error which ,g independent of the p rognun ..,an, for eKamplc

failure of Ih~ p<lwcr to an cxpan.ion unil or an

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. 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. 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

warm restart, hot restart); monitoring of Ready signals or modu le parameterization: maximum amount oftime which may elarsc before a warm restart
f>

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 Numb-er of relent;ye memory bytes. timers and counters; spec ification of retentive areaS for data blocks

> Retenti"e Memory

(>

Memory max . nwnber of lemporary local data in the priority dasses (organ ization blocks): max size Oflhe L stack and numberofconununi cations jobs Interrupts Specification of the priOrily for bardwarc interrupts. time-delay interrupts. a.<yn chronous errors and D?VI interrupts; assignment ofpanial process images with process and time dclay interrupts Time-of- Day Interrupts Specification of the priority and assignmems of partial process images: spec ification of tbe start time and periodic ity Cyclic Interrupts Specification of the priority, tlte lime cycle and the phase offset: assignment of pania] process images cycle interrupl< Specification of the priority: a.signmcnt of DP maSler system and partial process images Diagnostics/Clock Spec ification of the system diagnost ics; type and interval for clock synchronization, correction factor Prolection Spec ification of the protection level; defining a pa<sword; setting o f process or debug mode MU]licomputing Specification o f the CPU number
Synehl"(lnoi.l~

f>

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).
3.1.3 Spccificatiotu for Progra m Processing
f>

f>

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>

I>

c>

Geneml Name of CPU, plant identifier, location 10. scllings for MPI interface (if the interface is not combined with DP). comment Startup Speci!ies the type o f <lartup (cold restart .

(>

f>

(>

96

3.\ PmgramProcessing

T~bl~ 3.1

SJMATJC S7

O,gan i z.tiOI~, :::"''-------------T---';;;;;;;;'--' "'~

,
,
0"

Modifiable .

,.
modulos
Wi th ... tu>. update

16 to 2J

PROFlBVS DrY I
,or mOOe

"

tech no1_

In the c""" "f lo., of redundar>ey "'"'",.,

"Co,. ' ~ I

1n th e C05e

ORRI
OB
~5

toOB ~4, g6.g7

:~~c c. c
failure,

Sloer",' .

OB

~8

26 2) 2 5 2) 25 ) '

'" " '"

" "

2 to 26 2 to 28 2 to 26
No

2 <026 24 to 26
No

N"
the em::>'"

"

t>

integrate<! function Ac tivation and parameterization of the imegrated functions Communication, Definition of ~o"nection reSourceS

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. Proll:rllm
len ~.'th,

t>

memory requi,-., menls

"" Web Activation of the Wcb 8crYer, language se_ lection

Th e memory requirements ofa compile<! block ar~ listed in the block properties . If you "elect the bh'>cK 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. 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 PROPERCIES). On the "Blocks~ lab you will find the data " Size in ..."OJk memory" anod "Si7e in load memory". NOle that the configuralion data y<tcm data hlocks) arc missing in the value for th~ load memury. The SIMATIC Manug~'f shows you h l "c k~ in the demi\ vicw with the container open (displayed as table), and the memory TIuirements in \he staru~ line (bottom right in window) with the Sy.'lcm dOIQ object selectro_ With the progrnmming device switelxd online. the cunen l ottupation o f the CP U memory is sho"'-n by Ihe SI;\lATIC Managcr under PLC .....
DJAONOSTI,/SE'lTI-"O
~

tied by the systt= function DilL.


MOdule ill

S ~'C

84 \'lR1T_

Innov.I~...J S7-CPU" PROflBUS DPYI slaves and PROfL ET 10 de'~ces am :mppnn func'I lions 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 1 0 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.

M ODUll

I-" fOK. "t~

noy.;, " Memory" tab.


Chccuum The progt1lDI editor grnerates a eheel<sum for all blocks of the u,;c,r program, and stores il in Iltc objc(:t properties of th" B/oc/rs comaincr. l\knlical program~ have !he sarno:; ch~"Cksum, ",ach change in the program al so changes the ch<x:ksum. A checksum i.~ al~o g~e"'ted trnm Ihe system d"ta. You can view the cheeksu"" in the SIMATIC Manager with the Bloch con ta iner .ckeK-d and EOIT - t OUIECT PRonR

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 <ksign~thm IUId Index 16li0009 for the location 10.

"\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

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 !<elf-<':oDlained. and should have a lechnological OT functional ~is. The<e program sections an: refcrred 10 as "mocks". A block is a section of n UMr proif\lm "hieh is ddhwd by it;! functi on. ~ lruCt U'" or intended purpose,

'"

3.2 Aloc ks

3.2.1

Rlo ck TYI'es

FunCiion.I' (Fe's)

STEP 7 provides d ifferent typt".' o f blocks for dilTe rent tasks:


>

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 bloc k 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.

I>

Us~r

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:

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 .
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. Sy.tem h loeks 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. 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

Orx""izar;oll Moe,,",' (OBs)


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 <ftganization b locks have petlnanen tly assigned nutnben; based on the event. they arc ~al1cd to handle.

FUllction blocks (FE .)

These b locks are parts of thc progrnm w hose


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<sign a dirr~rent dma b loc k (w ith the same data 'inlCture but conta ining different v alues) 10 ea ch function b lo"k call. Such a p ermanently assigned data block is ca!letl an in stanc e data block. and the combination or fund ion hlock call ,md instanc e data b lock is referred to as a call in stance, or "inst ance" for short. Function bloc.ks Can ,,-Iso save th e ir variab les in thc instance data bloc k of lhe call ing f"nction b lock: tbi8 i8 referred to as a " local instance"

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~.,;

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~

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<J1 (in the offline container) Or present on the Cl'V (in the online contain~'T). Table 3.2 shows an ovcrvicw of the numbering ,}'Stem for ,ystcm <lata bloch.

;>

The declaration se<:tion, in which the block-local v:ariablcs arc d~darcd. tha t is, defined

t>

Standard blocks

The program <e<:tion, which contains the program and program COnll1lentaty n,e block header contains lhc b lock properti~s

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>

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

""

3.2 Block!;.

;"", ,,,o,,:,,.," .. .,"", , OO~~"".,m,m""', ___~ ,,,,,-, , ,,,,,m, .. ",,

...

Logic b lock , sourc"-orl"nt ,,d p rogram ming

Blockfleader

Block type Address Block head9.

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

Block I>c"dcr

I
''''
In itia l value

DATA_BLOCK Aadress BJock h9lJder S TRUCT "!!me , Data name: Data


t ype:~ tyP": ~

I
-

Decl6relion
Address

INama
J

-,..
.~

...

InrualizBtiQn: Initialization;

II
i
,

END STRUCT

I
I I

BEG IN

name

.~

Initializa tion;

END_DATA_BLOCK

II:

Fi ~n ,..,

3.2 StructUTC ofa Olock

l>

The initialization <""lion, in which initial values can be sp~cified for indi vidual data addresse"

3 .2 .3

Block Properties

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".

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_

,-

r ____ _ _ r 0 ' ~ ~"'"_ ~ "" ....c r


W " ",,", ",

"'""-""" 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 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<! in work memory. direct acccs~ is no longer possible_ Data in load memory can be read U$ing sY$tem functions and - if the load memory is a micro memory card - also written, DMit blocks with the Unlinked attribute are ~uitable for record ing data which arC only rarely Hec,,~sed. e.g. recipes or archi,,, . This attribule is switched off lIS standard. but Can be clumg! at any time u.ing the program editor_ The keyv.oord with .ou!'CConented program inpul for switching on this
ftltribu\~

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 dht 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.

is

UNL~KED.

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<l off ..... standard. bUI Cilil be changoo 01 any time lIsi~ the pr0gram OOitor. The kC)word with wun::eoriented

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
Howe,.. r, Ihe interface connict generally as a "time stamp conniet" caD alw have other caUSe'_ It aIM) occuu if a calll or referenced block is younger than the calling block. Example. of the OCCUT1"'CnCe of time stamp connim indude the followilli '
descri~

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.

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.
A func:tion block ;5 younger Iban its instlnce data block (the in stance data block is generall from the interfuce d:scription of the function block and should thO'Iefore be }'ounger than orlhe ~me age as the function block).

3,1.4

Block In tufacc

I>

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

> 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 <:&BI 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. TIm", , la mp .,... met
A time stamp conflict tXC1.tR whnr. the interlac.

Tbc Program Editor ~uppons you in different rna Mers in fmding and CQJTtlng in~a1id block calls. Sc-e the next s<C"licm r(lt" how 10 check the bloc\' ronsistmey in a complete program ("Checking block eonsisten<:y'l
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

"'hen cbanglog the name and type.


With EDIT ...... BLOCK CAU. ...... CHAl<GE TO .\ !t:LT1~STAl'CL CAI~ and "orr ...... BtOCK CAI.t ...... CIIA:<GI TO FBIDB CALL you transfer calls from function blocks imo local inst~nce calls or inlO calls "'ith data block. following mO<i,fiCBl10fl of the block calls_ you m""l regeneraie the associate.:! instance data blocks.
A f.lJ\her p<.>S'iibility i. provided by the menu command FD...E ...... ClIECK AND UPDATh
ACCE~S."The

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!erU5 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.

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<Juire editing,

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,

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.

The Program Editor displays the progre<s and resu lt of the consistency ch~",~ in the output w indow (VII, w --> ERRORS A'ill WARNINGS). "lbe e ons;s t~'ncy check CaJI]101 be nscd on progr~m s in li braries,

lhe pTogram ha, been compiled u ,ing version of STEP 7, .elecI PROGRAM --> COMP I ~E in this w indow,
an
earli~r

bec~l1SC

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:

. ."
'
~o
~,

....u ..... [1>1'_]

..'001 [ot """I '"",,''''L ' [DO ~l

_",",,' [M ' _J

"0"""""

(0'

"'I

... _ do',,- [<>0 """I


'(~["" -I

..... . "oj' [:0""'1

,'
'i'
- . """-" I'" '''",I "~;:~ [''''I

."

",

0 0., '" Q '""" :;c.

," [C<'-I ~'-I


:eo &t~ ]

o o "Ol '"," -"""..,. [""I C at l"'l .Q o COt ........... L>"'l "", _


_

a """ _1....""' .. _

... "-'""'"""' 1 ''''1 ...... :=1


.p". . . ' 'w[RO) .F" ......'

..

"."..,..' [1'' '....1


.,....,.,. I'" ' ''.-1

0 ""
0 "'"

COl'
( "' ~ l

o CO!

~o..o'r_'''''''''[MO)
_

.P". . . ' [nol

.".......""... ' :""']

ot'" ('" """'~l OI' !"I':

Fi~Dr~

3.4 Exomplc of!h< Repr< oon"'tic" of the 'Check Block Consistency" [kp<ndcnde,

]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.
aa1 ...

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.
t>

1n the Edilor "'ith menu command FILE -+


NI:\\. which displays a dialog box in which

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.

you can enter thc d~sirffi bloc k untler objecl nom". 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 -+ CusTO\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"

J,J

Programming Code Blocks

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

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 doubledocking. 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>

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). 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.

In order to declare a "ariMbk, sekcl il5 type;n


,",01 ~"cry type

In the SI MATIC Manager by selecting the 81.,.,h ohJt to rhe left half of the project ",-indo,," and generating a ncW block with ll'o."SERl -+ S7 aLOCK -+ . You are pro-

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

'06

3.3 Progro.mming Code B loch

'jo"

_n'"" ,,,' __ ~.~ . ' '''' .... , ...".. .......

,~"

..

,.... ,-, . ,-,


,~

-.,......_. _. ...... ....,. .w._._


... h.' _
., ... _ . }

....--.0_,

,_.
"... . _ _ _ _ _ ... _ ___
. ~_.

M __

~- - " ......""

:3

t ]litu ....

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'".
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)

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).

ors

uepcnding on thc Ednor'. dcfauh Serling' the fields for Ihe block li lk and the block commen! anu,

In the program window,)'Qu will see

Table 3 .3 Variable Type. in the


Vatl""l. Type Input pat:amete",

O~d.rarion S.~llO"

Oed. .... ti""

P" .. ibk io moo .. Typ<'


K K K

OutP"t peramet"'"'
In-aw parameters

St.l ic 1 1data <>Ca

OUT J.1'. _O UT STAT

"

,. ,. ,.
,. ,.

Temporary local da .. Fune<ion ~ alue

"""

08

RETUR..'1

,e ,e

'"'

3 SL \tATIC S1 Pr<)f'l'II

if il i, Ihe first I>('twork.


..
~ode

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

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 ",Cment~

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 KIr ea, b lI"twor~ drrcctly wil h the Illenu COJlUn~nd l:'DlT ~ Go To --; ....
,,~

'"'
JJ.3
The
O"frvl~"
ov~rvie\\'

Window

clement

~PtIllO

window contains :ho: program owd the call rnue=

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
~

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<

" 'ith L'SERT


,"~c-n, In

r J)(iR.\ M U.ME"oiS .

l"1:TI'oORK. Tbe Editor then

eml"ly

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) .
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

network behind the curremly selected network.

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.

th~

JJ.4

Pro~rammln~

l\"crn'orkt
FI"u ~ 3.~

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-

Pro!!"", !':l<m<"" C .tal,,~ fu, LA!) and )"fIll

'""

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). 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. J'\etwork templates
JuS\ as you store blocks in a library to reuse

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.

3.3.5

A ddres . ing

The add",>scs used in th~ pwgram, such as inputs and outputs or bit m"morics, are addressed in absolute or symbolic mode. Absolut e
~~ dr","inl:

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

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 a<ldrcsses and parameters are corr"c!. You ean deactivate somc of these type ebcch (in thc Program Editor under OPTiONS ~ CosTO MIZE. "LADIFBD" tab, "Type ehcek for addrcs>cs" 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 ,

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<l"<'cs container in a library). Tryou want 10 us~ Ihe n etwork tempiat'", open the rele\'ant library in the Program Elements Catalog and th ~n select the desired network templa1e (double-click or drag to the Ed itor

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<i<;lress, and pos.. ~ also assiifl a symbol comment This sym boDIlStocn transferred to the symbol table "'ben
~d;ekOK.

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),

y(RI can a1 edil the symbols in Regi ster "4: so 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).

;. 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).

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.'CutioorcleVllllt 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 .

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.

1'' _

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.
1at:1

3.3.6

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

Colt,
Si:nJ>1< coil
C~:I

c",,,..,t . . itlo .".,.,;.1 1\.0"",.",


(e.". ncgouonJ
BoUI

"'11b "'I'P1clr.tWy IItfICh<ttl (~.II. set, use<. ~II<'

...... 1"."0<10< jump functioo)

--jNOTj--

S<and:ard boxeo ... "houl EN..'I'''O Ie-.. tim ... ...:! 0.,...,1<, fuDct;om)

: ''" ,
Flilun ). 7

_.......
S PULSE

SIu.dttrd b<to... wttb E/>. ''0 ( .... ari<lllMtic ""'-1

Block bo~ .. (~ ... I"w1ctiI>It block ""U.)

D'm

" 1= 'CDeof LAD Program Elemcn"

.,
in3

.,

eo"

'"0

I:>c~mpl tj;

'"

3_3 Propmmina; Code Block$


" . lwo~k

"

~.rt.

r.~ay

to ' Oy.
<>f

. .,

an

~ ...

pa,u

h~v ..

, . . ~he<l tn .. or."

tn. bal t , "< noy or. r ... dy

o~

u.<> .... l .

- ... u ..

{p -

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).

Layout

re~t dctions

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_

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.

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

'Vhen LL.ina

bo,,~

as program demenls. you

'" po
po po

program a single box per networi< arrana;c hoxcs in T brancht~ ;n branches thaI Start"t Ihe left power n,i l
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 I ,,-.. es has be..n prox cessed without errors in the cas~ of paran~l "onnection (see also Chapter 15.4 U.ing th~ Binary Re~ulf').
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 .
Hin~ [ )'

fUll ction s

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

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. 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

O pCra!lOn .
Sim ple
b"xe~

"
!>

with the functio ll key, (e_ F2 for the Al'-"D function), g_ via thc m enu
(L~ShRT ~ FBI) LA"UUA{;F ELE.'-!~_"rS ~

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
)ah~L

from thc Program TIlcmcnts Catalog (with INSERT ~ PROGRA.\! J::U::lI.Jr.-rS or


V tEW ~ OVERVIEWS) .

YOll tcnninate a b inary logic opcr"tion in the simp le't case "'~t h an ass ign box .
Binary fu nction.

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 O IL
addr~,s _ ~ya)ua!ing

Th~re

are simpk

box~,

}\;jd ftu-",'i<m.
.: ORfuo"ion.

l!~:,l o.<i".--O R

fu,Id;OO

Nega'io>~ or""'D o.nd ,..,sul, of


lli~ logic

"1" ""-'''''''

L L mR L
> .,
""_'">

Slmp!e bo x..
~."""
fl..ct;

8 inary operand

='=c-<l!~

","'=ti""
(;('.<\1",1

--l

I
CO

tltr.... ..00 Ju"'<r t'>noli"""

Counter o p-eraoo

--1

ju,,:p !"n~'w=.
,,,,,,,,or =!to] ",loy, <le_

Complu box
S ~Qdan:I bo,~whh<>u' l'I\! n~O

_ (~,!!.\ir"","~uJ " U"n~ 1"""t;'-"'


Time"- ad<:lress
S 1'\1
S PU LSE

SuotI.,.,r wilt EN_ 'EXO (t.:,: mtbm<.-ti<> f!(...clioo>}

fll<d. "OXO,
(~ IO.

tunc,;"" hlock calls)


DB.m

81
Q

, eo

BCD

= -

"

out,
oul2

f-

in ' in2

,"0

Fil:ur. 3 .9 Exampk, ufFBD PrugnmElement.

3.4 Prognunming Data U I()<;k.

~ o. ~

' E>'

R.,.o"."

". "

1-0

" ",

~,

"

"B u ie u" _ "/II{a u ltl"


fl~ur e

L .
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<i in the relevant ehapteTh. When us ing boxe, as program elements, you

3.10 Exampk of an FBD Ketwork in "3.Dimcru;onal" Rep,"s<nt.>tio n

Comple" boxes Compkx boxes represent program elements with compkx funnion. ST EP 7 provides "standard boxes' in f\<.'o version.!:
~

wit hout EKIENO mechilflism (,neh as memory functions, timers an d ~ O\lntcrs, ~omparison boxes) and witb ENIENO (suc h as MOVE. arilhmetic and maTh funed<Jns, data type conversion),

""progrnm a single box pe, netw ork


;>

!>

arrange boxes in T branches in branches thaI stan at the left power rail 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.

If Y<JU call code blocks (Fe s, FBs, SFCs and SFBs), FB D also repre,ents the "all, a, boxes with EN/ENO. 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 , 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, 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

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,

3.4

Programming Data B loc ks

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, .'

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>

Dala block referencing a user-<iefined dalll \)1'<". or 'ODB of ty~.' Creation as a data block of user dam type; in thiJ; "".e th~ dam .Iruettlrc is used whi"h you h."e declared when prollrAmmil\g Ihe c;:<I!Tespondiog user dam type t:DT.

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 <illta block on the "G~"1lCTll I Pan r' tab (I Chapler 3.4.2 M Types of Dl\", Bloc~M). Instance DBM and DB o f ~ pc n onJybc "1led iffurn:uon bloc~ FB. S)"S[cm function blocks SFS or user dal~ rypes UD T are present in Ihe blod,: contaioer. You can also enler the ~maining block properties lale!". In Ihc program editor: "'ilh FILE ...... NEW. you get a dia log OOX in which you ~lIn en ter Ih", d<;.;rcd block 'md~r Object name". In the dialog window New data block' which i ! 5ub.'e.:juc nt ly displayed. you arc requested 10 defi~ the ~-pc of data block (s<'C Chapter 3.4.2 Types of Data Blocks"). After clo!inll the dialog box, you can program th" bloc~ contenls.

I>

'Data block referenc ing a functi()T1 bl""k' or In<tancc OS"

Cf(;lIti011 as an instance dala block; hcre, Ih~ data " ruct u<c tbat you h",.. declari when programming \M relevant function block is frnnsfC"TTed_
U$er

Wheo creating a data block on the basil of a data \)'P". you simultaneously defme the u rn on whicb it is based; I.e. the liDT mUil\ already ha>'~ been presIIIlt io the block: ton miner. The S3me applies 10 !heereat;on ofa data block" ilh ""signcd function block.

t>

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. 3.4.2 Types of Dat a BI""k.

When opeoing a dSla block whon lIrueture is ba<ed 0<1 a user data type or a (5y.le.,,,) funclion block. you will ~ ash"d in the slnndnrd sen ing "hether you ,,-i5b to o pen the data block using the pmgram editor or the application Paramelerization of data blocks'. The parameter " iew prt,ents tbe data nlues arouped thnologically. and permits more con>enien! parameterization (...., Ch.aplcr 2.1.8 ~onj:oring and "'lodif~"U1g Data Addf(;s~s,. The datH ~ie"'s are d~riboo b<:low. The propam editor pmvide:; t"" vic,," for programming (cresling) dMa blocks: ;;. 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

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 applition;
I>

".

M Datll block Or Sha~d OS' Creation global data block.; ~ou decla~ the data addre",es wheo programminij: thc dHtn block in this CH.C

u.

Eacb ' - presents a table conlPining the abso.e" 1u1~ 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.

of the user J"t.~ type or from the th~ fundion block.

d~cI "r~tion

of

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<s lS ass igned a deb.ult va lu e . This i, Z<'ro. the smallC8l value or empty d~pcnding on the data type . You ca n modify the ddau lt v~ luc in the initia l v alu e col-

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 .

"=.
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

115

3 SIMATIC S7 Program

view

In the offline win<1ow, y ou roit the ,"'''' in ,~c ofllin.< data ~lOna~<m<,, 1.

In Iho vtiliJ,. "ind<>,". Y"~ monitor the da", in

the CPU'. won: memOlY

I'

U,eHTT --+ SAVE 1<' wri t. ll ,. aotual

val". imo t h< offline dato .

to write tho &rual val ue ;"to the load m em o,),

an" won: memo,),.

'[ ~~efam! va,IU.BT.-.:

..

':~

Initial

~alu"

- lr-~,c,c,C,"C,~.~"C'"~.-'J .. _:I;;:~AO~'C"'.~'C"~.C'"C "


Load memory Wo rk m"mory

OHli n. dato< in the prog ramming davlce

Hgur e 3.12 Data SL o!"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 T TIAUZE 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

3.5

Variables, Constants and

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_ ---> SAYE . you t: write the value in the initia l value ~oJumn "'" the

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 aigning 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 <ii;:i'''/

3 .5.2
Wh~n

Address;n!,: Va riables

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

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 .

[>

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 <ta\cm~n" . T he!"e are special functions for handling (hese variab les, w ch as the IEC fun~tions, wh ich are pJ"<'widcd "-~ "standard library with STEP 7 (you can generate vari ables of com plex data type in block parametcrs orthe <am~ data type). If variables complex data type contain com pon,,'ms of e lementary data type, the<e componems can be treat ~d as (hough they were separate variables (for example, \lOll ~an load a

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

or

A v>0a..u;, """sis" ""d",u and ,1>8 da,~ 'J'P"Hi J~.><>d 'y""'xJ;Cd#y,

01"".

Va_a ble i

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

..

Memof")' location

Fl~ ur.

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> t>

the byte containinR the vari able . n ,e addre" iMmifier is supplememed by" B, EX3mplcs;
ill 2 inpm b)1e no. 2

QB 18 Output byte no. 18


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
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:

QW 20 Oulpllt word no . 20;

1 bit

Data type BOOL Data type BYTE or anmh~r dala


type with I; b its

8 bit, 16bit s

t>

DatatYP<'WORDoranothndata
l)'pC w ith 16 bit,

ID g

t>

32 bits

Data type DWORD Or another dala Iype "ith 32 bil'

Input dOllble"ord no. 8: conlains b)~es 8, 9. 10 and 1I Output doubt.word nO. 24: contain, byle' no . 24, 25, 26 and 27

QD

2~

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: I 1.0 Input bit no. 0 in byte no Output b it no. 4 in byte no. 16

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

Q 16.4

Variabl e, of data type BYTE ha"e as abwlUlc address the address identifier and tt.c number of
QD, 2"

QW24 , OB 24

OW 26 ,
.. 1 07 ." .. ,07 .. 25 OS26 CB27

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

"I

os

QW2S

F11:IlN 3.1.t
Byte Co ntent! in Woru.; and Double" ",,<is

''"

3. ~

Variables, Con Slan ts and Data Types

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 <ymbol8 and symbols thm ar~ local 10 a block G lobal symbo!. You may assi!{T\ names in the symbol tabl e to Ihe fo llowing objccts:
r> r> r> r> r>

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 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, ram r input , You <:<ill subsequently ~ont;nue program input w ith the new ,ymboli c name ,
TfYO li eon'piic .. "O lireC I~XI file geaerated c.g , [rom LADfFflD blocks . the complete assignnlent o f symbo lic name~ to absolute addresscs is only made avai labl e during the compi b,t ion.

])a13 b locks and codc b lo<:ks Inputs. outputs, peripheral periph<.-"TaJ OUlp"ts mputs and

Memory bi ls, timet> ',nd eo"mer.; User data type5 Variable tables

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.<t put the symbo ls in quotation marks in thc program, In comp iled blocks. th~ STL Ed itnr a lways shows global symbols in quotation mark>.

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 :<tructures, caeh sub identi!1er is separated from th e preceding subidentifier by " dc~ imal p"in l> ro r insrance FRAM.E.H EADER .CNUM. Component.< of ",er data lypeS a..., address~d exactly like structures
J)atlllldd~ess~s

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

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.

(n bits)

J.!.J

O,tni.w o rD llal)'ptl

Da\a \~ ,\i'llU\a\.e me cn:!.!amris\ics of data ell5enlial1y the repr~>;cnlalion orthe COntenl, of


a variable. and the permissible rangco. STEP 7 provide!! predefined dala types. which you can c<>",bin~ in.o u_= dIt", !ype>O.

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 progrDm "Data Types" program that yon can download from Ih<: pub lisher's Website (<ee ~ge 8).

The da\a ')"\'ItS lIt avai\ab\t on a ,\oba\ basis

~~~~i&..~~~\.J...\\~~~~ "~";he-;;;;;e"1:llI'"i;:P;:,.
Depending on stru~IU", and application. Ibe data types with STEP 7 are classified as foilows: dallllypu
typeS

3.S,4

EI~mtntary

Dalalpn

f...u.~<u"~~"'<:&.~~(..'"~'"I:t.'\....,,~
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. O llra tioD of eleme ntary da,a types

11o---....."'['<~tttenmry I
I>

> CompLex datil


lj5Cf

data type. :> Parameter 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
, [

Table 3.~ shows some elUlmplcs urthe declara(ion of v8riable. of elementary dala ~s.

""

3 ,5 Variables. Con,tant" a"d Data Types

TabJ~

J 6 O"erview ofElem<:ntary Data T)1>C'


( Widlh) ( 1 bit) (8 b its) (8 bits) (16 bits) Dc,s cription Bit Bxampie for C<>nstJhl Notation
FALSE

tJata 1)l'"

"OOC
BYTE

TRUE
8-bit
()'w
b~xade<'imal

BiI' [6R1Xl, 16#00


BilINiFF, 16/!f1'
Printable chanoclcc, q!:. 'X

number

CHAR

ch ara,tcr (A Se!!)

WO=

16-bithexaJe<lllla.l
tlum bcr

WII16'1oooo,INiOOOll W~l61ifffF, J6!iFFFF 2"OOOO_ooooJII)()(}_ OOOO ""llr l 1111 111 1 Illl

16bil b inary number


Count ,alue. 3 ,let'.de. BCD Two g_hit u(1,igned dccim~l numbc'n;
DWOIW

B II(O,O)
UII(255,25~)

(32 h its)

32-bit he~adecjm. l number

D WJJ16"OOOO_ OOOO, 161iOOOO 0000 DWII 16 t1 frfF]FFF,16li' FHPJFFF


2'iOOOO_0000_ .,_0000_0000

32-bi' binary number


Fuuc Sbit un,ilP'eJ

l ll llll 11 11 LI#(O,O,O,O)

111 1 l ill

dedmal numbers
(16bilS) Fixed.point numocr Fixed.point numbt'f

BiI(255.255.H5,2~5)

32768
~32

767

(32 b il.)
(32 b i!

LII-2 147 ~83 MS t ) lll+2 14 7483 647') '. -I.23 4567E+02 2) in exponential rt'pY'C<rntation

float;ng-poim "umbe"<'

a, de<:iII1al cumbcr
SSTJME
TIME

12 3.4567")

(16 bits)

nme value in S L~lAl'lC format Time


"alu~

SST SST!MEif2 h46m30.


TiP'-24d20h.l 1m23.64 7m. n",lEN24d20b,llm23.&47m. T#--24 .855D4d
nMEII 24g~5 i34d

;4),,,,

(32 biLS)

in lEe fo. -

mat

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.

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<X'ial ChaIl!.ct<,.. fur CHAR CHAR
H~

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. Special fon n s of the,e data types are the Bel) numbers and the count ~s l1<ed in c<)IIjundion with counter funCT ions, as well as data type CHAR, which represen ts "" A SCll character.

n...,ription

, "
Sl or $1

17h....,.

4 2 """

Doll.r sign Apostrophe


L in~

SP or Sp SII. or Sr

"00
OC
mJ~.

fel {lf)

No,.. page (rt)

Camaie re"'m (LK)


'hb,,]alo[

S'T '" $t

09."

BCV n~mlx,r,'
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.

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.
T"T

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 w<mllhe sign is in the uppermost Meade. whe",hy only bit position 15 is ",levant. Sign.l1 state "0" IDCan, that the number is po5iti\'e. Si!!ll"i state ,. ," 'tands for a ncgati"" numbcr. The sib'll has no afleet on t.b e comeot\ nf the jod i' idual decade " An cquival .. ot a>signment 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.

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 "I is stored as a DL T variable wh .. n it .. xceed, 32 767 of falls bJow 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

Data typ" CHAR

.".

.
,

.
1 0 \
Byte m+1

BCD number, 3

dee~d

ASCI! Cod.

S;gl1

BCD num""r, 7 deeadu


Byte m

Bytem+2

Bytn m+3

"

28127
Sign

24 123

20 [ HI

Om type INT

15 14 ...

D~'" typ"

OINT

3130 ...
1S 1
D~UI

11> 15 _
"'.

d ;;

2302

2 ..2'"1'" ..

... 2'2' 1'1 :


... 0 '"

Iyp" REAL
... 2322

3130 .

Data type S5TIME


15 14

,
... 0

D~"'ty""DATE

'I','"c,'".','''.-,------------,~;'-""~~I '
,

1514 .

,, 'n !)

Data type TIME


3130... .16 15

':: '
'~"I~", .'

30 I5I2 2",...
Data type TIME_Of _DAY

... 6 " " .

"

3130

... 1615 ...

, 0

Sign

3 SIMAnc S1 ProJ!I3:n

A variable with da.~ type DiNT re,erYCS one doublewoml. Th.o: signal <ta.cs of bus 0 to 30 represent .I>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.

A dc-normalized floating-pomt number may be in the followin!! range: LIn 494 x 10- 31 to -1.401 298 )( 10"'"

.. 1.401 198 X I~~ to "'!.l73 494 X ]()_Ja

'0'

REA L
A variable ofdaU-type REAL represents. fra~

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<mnal i 7.cd no~t ingpoint tmm~rs). Table 3.8 shows the int er_ IIBI ranl;c ofa domiog- poinl number.

lion. and ;5 ~w..ed liS an-bit flrnning-poim numb<."T. An i ... tllC1" 1~ ,tore<! as a REAL v&ri.ble when you add. decimal poinl.nd II z~-ro.

In exponc:rJ! ",pret:ntalioJ!, you can prcde 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""tinapoin. number lies between, 3.402 823 X 10-l8. 0 - 1.1 15494 X lO-l8

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.$

'"
i

and milliseconds. STEP 7 handles convc ... ion


in to imernal repre5enta.ion. Internal
1'q)1l'$C11-

1.17S 494 X 10 U to -30402 823 X 10-;8

Tabl .. 3.M Ronge Limi" of a Floatini'Poilll Numboc r Sign F ponent ....


Mano.>:I

Dc..::ripuotl
1'01 " '~hd IOooti"".po"" nurnl>er - infmitc Po.ili,. _li,,~d foatlnll _poinl oumber 1'o.ith-e don:or!n.l,,'ed tloatina-poun number
~

0 0 0 0

'" '"

0 0 0 0 I ... 2S4

..

Not equal to 0

. 2~4

""',
0 0

Noc cqual 100

,=
II'"'pli"" dcDomIahzed floatm&-poinl number 1\'pri'" nonnati2ed fioaUJIa-point Dumber
infinite

1'01 equal In 0

Arb",..f")' Not equ.al to (I

'" '"
'"

1\Ot . ,-..ljd floa,ina-poinl IIUml=

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; S5TIMEII'500ms S5T#2h46m 30. 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" (- 005 0t,eJ (- 3999 h< . J

a decima l point, may be omitted


E ~ample"

TIME at' DAY#OO:OO :OO (- OOOO_ODOO b,,) TOD#23:5 9: 59.999 (- 0526_ 5BFFn.:,)

3.5.5

Comple:.

D~ta

Types

STEP 7 de fines the following Four complex da!a type s '


t> t>

DATE

A~ D

TlM r

t"". .

Da! .. and lim e (BCD-coded)

STRING Lnaraeter string with up to 254

Chaf3Cl~TS

DATE#1990-D 1_0 1 0 #2168-12 -31


Tll\lE

(- OODOj,e, ) ( = FF62 tcx)

> 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)

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<! as a signed 32bit fixed- poim number Examp les: TLMT.!l24d20h3 1m23s64 7ms (- 7H'F_ FFFF h<> ) 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

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. 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).

TIME. e.g. T IMEII2.25h or Tlt2,25h. bM mpies: TlME#O ,Oh T IME#24 .l!55 134d
TarE_O t' _DAY

(- OOOO_OOOOt,.,,,l
(- 7FFF JFF Fh)

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", <epa rated from them by

125

3 SIMATlC S7

PrO~'Tam

Tabl~ 3 .~

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

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_

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)

tial value . Figure 3. t 6 show, the stntCl<l re o f a STRTI\G variable.

Data type ARR."..Y r~pres ~nt' an array or fidd compn$;ng a ftJ<td number of elements of the same data rypc . You
,p~ cify

brack~l'
in; (i~!

the range offield indices in , quare following the data typ" ARRAY. The ,alu c (lU 1he le n must be less than Of

o.ta format DT
8;'('~

a.too form8t STRING

Yur
Month

o bi$ 99
1 bis 12 1 bi$31 O bis 23 Ob is 59 Obis 59 Obis 999

B),".e

Maxlmurl l<>nglh AC".llall.. ""th tstcltua01e-

Byte n+1

8 y"" n+1
By:e n+2 Byte n+3

',m "
Maximum leflgllT

Byte ..,.2

0"
Hc ur

..

Byte n+3

2r..d ::I>ar;ocer

I"e,~~

n+4

Minute Second

Byte ...
Byte n.m+1

..
mrn <;haracte r

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":"

'"

3.5 Variablell. Constant, lIN! lla.1.& l'ypes

Nam. MOA". v.1.


WO
Re~h

Typo

Inilla l V.lu<
0.4. I~. II

Comrnoms

ARRAY[l .24 ) RIOAL ARRAY]-I0,.101 TIlI.fE OF_DAY ARRAY(1. 14.1. 4)


OW

0.6. 3.0)

Amoy ,-ari.ble with 24 REA L clemenTs

21 (TODII01UO:OO)
%(1...-0)

Ton arno.y ,,~'h 21 d""''-""li


T,,"O-<hmcn..ional..moy with 96 okmC"D1i

"'"'.

ARRAY fl .V.AI CHAR

2 (...).1 (-b")

Th'o-d;mom;onal ",.,..y with 4 element.

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 .

ter ir Ihc bloc k parameter is or Ihe ... me data I)'pe: as the components.

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,

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<ed value in LAD!ll1d FBD and ~an DOl be moditied al rumim~ (no variable index. ins ponible).

PNt_as,<lgnment
AI IIIe declanttion SUllie, yOll can pre_a"' gn values 10 ;ndi\-id'-'3.1 field components (nol as 1 block pIIr.rnle-ter in rollClioD. as an i",ool pantmeler in a fun<:tion bl""k or as _ lemporary variable). The d ata Iype of the pre.assignment value must match the dala Iype O!"lhc !ic!d.
You do not require to preassign ull field com ponenls: if Ihe nlImher of preassianment VIII ues is less than the number offield components, onl), Ihe fi.,;1 componen1~ liN pn."-".sil!l1ed. The number of preassignment vMlu<:s musl 1>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.

Mlllrl-dim"n.<irma/ jidd< or arrays


Fields can have up 10 6 dimetlJiions_ Multi dimcn~'onal fields are analogou~ loone-<lim",,sional tields. At the d<,.~laralion stage. the tanges of the dimcn,;<ms ate written in sqUIITC brackets, each separated b)' ~ comma , Structllre

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<y up to the next ","ord boundary.
Component. of data t)'pe nOOL hellin in lhe leaST silP'i lkanl hil; cOmponenlll ...r data type BYTE and CHAR begin in Ih~ righth.,nd byte. Th~ individual componenlS are lisled in order. In multi-dimcnsional fields. Ihc compotlcnlS ..,.., slored line_wise (dimerulionwise) 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~),

Application
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<o conlentS of a field vanable usinSthe .~ystem func_ tiun SFC 10 BLKMOV. You can also specify individuallielu components at a block p"ntmc-

3 SIMATlC $7 Pn>gnun Ta bl .. J.1I hJ.ampl .. ofD""lariul! .


Name MotC",u
T,~ ~

1,,111. 1V.lut
FALSE

'''U~

""

Off

0.1.)'

"''''' '00'
,,~

TI<U,
S5TL\IE ~ Ss

SSTI\IJ:

maxSpu<I

END_ST RUCT

"'00

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<l of type lNT

STR UCT 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,
Th~ d~ta ~

$m<efllrc of t~e '"Qrillble~

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!<:<I m the memory in the order of tltcir dedllltiOn. STRUCT "lriab!C!$ o<;cupY Ibe memory up to the oe't word bowldary

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-

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.

nlted by dOL

3. 5.6

Pa rameter T~l'"

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:<! by. dot .

Para.nmerrypes are data I)~s forblock paramo etCI"$ (Table 3.12). The Icnt.h s~ifications in Ihe Tahle refer to the memory teuircments for block parameters fOf function block!. You can abo use TllitR 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 fteuenlly 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,

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:<ample'''' ,hows yon how 10 work wilh user data types , Creating (lOTs You can create a user data type usi"g th~ SIl\1AflC Manag~r or also the program edifor:
to>
L>

n",n\>ct (tM~ ab,olute a<klres8 UDTn) under "Namc" You Can also enter the other block attributes later. 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:<ten,ions in the program ~Jitor "sing FILE .... PROPIl~T!ES .
A double-click on data type UDT" in the SIi\1ATlC Manager opens a dcclantlion table Ihat looks exa~ tly like the declaration lahle of a data block. A lroT is programmed in e xactly the same way as a dmn b lock, with individual lines [or Name, Type. Initial value and Com menK The only diffcn:ncc is lhal .witching to the data view is nO! possihle. (With a UllT, you do not create any variables but only a collection of dala type,; for thi, reason, there can be no aClu.a1 "alue, here),

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

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. 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<b md "ariablo:< or 10 copy entire dala areas.
The timing relay. in comactQl" control syslenu arc timers in prosrammahle controllers. The time!'> integrated in the CPU allow you, for uan'plc. to proa:ram waiting and monilOrinS ti mes.

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"'.

,,'"

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
M~mory ru nelions LAD coil!;; FBD hollOt'; midline outpuu; edge (\"iuauOl1; cOII~eyor bel! example

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 <Ior( b inary S\a{C~_ The subsequetl\ sections or thc book describe the relDllinUlIl OJl'CnIld 8m1<, on whIch you can .Iso u"., binary lo~k Essen_ tially. these are the data bilS in global data bloch as w(l1 as Ihe lemporary and S1ali~ local data hits.

,
,

"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

''0

4 Binary Logic Operations

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:
t> t> t> to>
I> I>

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.

Input and output bits, Tim"", and counters Global data bilS

m~mory

bils

LAD has tWO kinds of eonta~t1; for scanning bit operands: the NO contact and tbe NC contact,

Tcmporary Io<;al dala bit.> Static local data bits Starns bits (evaluation of calculation suits)
r~-

,,0 <on'.ct
'-';C contao.

Bin ary operand

- I I If-Binary opeI';md

-I.1f--

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 .

N ormull}' open (NO) contact


A normally open contact ~OtTe5pon u~ \0 a "",an for signal <late" I ". If thc s~anned binary operand has signal , ta te "I ". the NO contact is acti""ted, so it closes and "power flows" ,

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'<TS) under "Bit Logic" .
th~

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.

4.L.1

1"0 C ontac t and /li e Contact

/Ii ormally closed (/liC) con tMct

In order to expla in the bit logic combinations in a ladder diagram, we will refer below a, graph-

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

,,<>do of &!l .,.tion of ~C contact

,I
"
' 0'

,
" '"

SM''''

octivat.d

,I
"
'0'

--

,
T

,, ~

oc Wa'~d

"

~H-r~
"
Figure
~ .I

r-w-r}- H+--ri- Ht-r}"


" '
~

'0'

'"

' 0

NO Con",", and r--C Contoc", SCt to "I ". In all otber case" no pmvcr flows and tile (Jpcrand Coill is reset to "0"", "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""

signal state is "I ", an NC cOma" "open." and the now ofp<)W"," i, interrupted. !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 .
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.

-l .1.3

Parallel Cireui"

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") ,

\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.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<lnlacts are closed. Figure 4.2 shows a typical ,erie, circuit. In netwMk I, the seri es circuit bas ,hr.econtac,,; any binary ()per~nd, can be scanned. All c(}mllcts are N O conIac\>, 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

4.1 Snies and Parallel Circuits (LAO)

SerI....ntctlop

H H

NlICWOl1< 1 tact1

""".~

II

"""~,

II

CoO'

( }--I

C.",.,,,
Coo_",

"""~,

I I I I I I I I Cl

I I

Coltl Nelwork 2 tllC14 Contaclt5

f1

C." ( }--I

Contact4 ContactS

I I

COO,

,....n .,.on._
No...,.' C.-,

"""_
Contact3 N,twork .. Contact4

""" )

~,

I I I I I I

I I I I

Coo.",

Contact3 Colt3

I J~t5 I

CO"

( }--I

Contact4

ContaC1S

co.

I I

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.

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

~h.r leo

"""n.."Io

,
CO.

t""'
-~.

I ."".on I

"""'"'"

~r- I
"""""' I

( )-----1

"""N_....k7

"""""' """"'" I

"'" )-----1
,

Strlt. a .... dom ..r ... ~ <UMflIoD.

II""' I Con~r4 -_. fl'" I ~: I Ii"


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

CoO'

( )-----1

CcWIO

( )-----1

4.2

Binary' Logic Operations (F BO)

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} <IT Conlocl2 is o~n (Ke the FifUre in the adjaCC1lt pulse diagram).

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.:
:> :>
I> I> I>
~

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.

Input and output bi". memory bits (discussed in this SCC1Ion) Timers and counters Global data bus Temporary local data Static local data bits Status bits ((valuation o f calculation
re"ult~) bil~

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.

E,ttY binary operand Can be addressed absoIUI~ly o. symbolically_ Wh~n <canning a binary

,"

4. 2 Binary Logic Operations (FBD)

NOT CU Dta ~'

(n.~ a t<

Roul, oflh< 10::1< 0 <cation)

N"twotil 9

r-nf--~II
N"twori( 10

Co~taC!1

Contact1
Co<tIi>ct2

INOTrl---<(

Coil9

)--I

Contact2
Coil9

I I I
.I

,,!
~

..

1.

OO.~ct3 NOT~I__________ ( )--I


Coill0

-<

Contact3 Contact4
Co~1 0

Contact4

FI~ u c"

4.4 Exomplcs ofa NOT Contact

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) , 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".
4.2.1

thc scan.ned operand is negated prior to exec lltion of the logic operation (see below).

OR

fu~ct!on

Exo!m;w_OR fUDe';""

~XOR

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<rand can

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.
CbL fo<
.j~nol ll .t . "

Ele rnen l ary Binary Logle Operation s

I"

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

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"

11 .0

Function box

" " "'


4.5

, , -\1

~,..l
11.0

,I
-,-

C bd.: fo r . ignal "at< "0"

s.n.".. -~
" '

"

,I

.....,, , \1

&.01.01

..clN.",d

'"-,-

'"

" .,'
"

!t.1

Fun ction box

Function bo"

Function box

fI~~""

S c ~nniDg

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.

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

ir.put ---j

8. I {:Jc:}-----["~'E"":JI

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 ;

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

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

42 Binary Logic Ope ration. (FBD)

A.",' n fu nction
Netwllrl< 1

Inputl Input2 Input3


Network 2

,
Outp<Jtl

Inputl Irwu t2 l"l'ut3 Outpotl

I I I I I I I I I I I I I I I I I

.....

-' 1 ..
,
,

,
,
',I
"

Inp<J 14 InputS

==d , ~ OutPUt2
~""

Input4 Input5 Outpul2

I I

OR fu"<tlon I Network 3 Input l In;:>ut2 InpuO


Network 4

InpUl l Input2 OI.ltpul3 Inputl Outp"O

,<
I I I I

I nput4 ~
l"put5

> I

Input4 OU\j)IJt4

,,
O
,

Outpul4

""""

E ~du. i, . _O R

I\tncr1on
,~

Netwllrk 5

Inp"tl Inpull
Network 6

~o...lPUt5

Input t Input2 Outpu l5 Input4 Input5 Outpu\15

I I I I I I I I

I I I I
,I

Input4 Inp ul5

=:d. xoe ~OUtput6

, 1 ','
I

mi

I'i~ur.

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<! , If on e or mor~ of the operands scan ned h ave signal Slat~ .' \ ' .. th e neX t ,tatCme 'H set, th ~ operand

137

Binary Logic Opt-nliom

Outpull 10 "I ". If 1111 of Ihe open1n<!s scanned have signal Stall.' '"()". Ihe OR condition is nol fu ltilled and oJ'Crand OWl"" I is reset 10 '"0" .
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<l5 1Ia~ II .ignll\ ~tale of'O". Eadu.lve OR fu nction 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<l1O Ih e Exclusi ve OR fun<:ti(ln. If <.Jnly One <.Jf the opcmnd, scanned is "1 .., the ExcllL~i, e OR e()n dilion is fulfilled and the oJ'Cmnd o..lputl is sel 10 "1", If both Operandi lire "1" or ''0''. opmond 011'1"'11 i. 1"<'5el iO ''0'' \;"C\Wor\c: 6 silo"" an Exdus,,~ OR function "'ith a negated inpUT. N"ea;<I;()n is rep~ed by' circle. lbe scan n:.ultofa negatedopera.nd

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. 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

--I ~.

~.2 . 2

Combin~tlo nl

of Sinn)" Lo"k

O p~r"llon l

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 "Tbraneh" in Ii loic 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

,
OU:pu\8

,""'" Inpout3

'OR

.., I

,..,...,
~
~,~

Inpu!7

4.3 TakinJl ACOOWI! o f me Sens<>.-1'ype

NAND fUn crioD N. twork 7

Input! Input2

,
~ """"

InpY I1 Input2 Input3

I I

I I

'""'"
NOR

I I I I

0''''''''

I I I I I
I

r.l><1lo.

N. I _ 8

Input4 Input5 Input6

..,
"""",W
,

'-"
Input5 Inpul6
""'~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
rqIOl'1cd.

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",

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. 4.2.3
N~Bting

4.3

Ta kin g A cco un l of th e
S enso r Type

t he Res uh

oft h ~

Logic Operation 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). beru'ecn two binary functions (which is equivalent to nc=gating the =ult oftbe logic operation). or 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"),

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 fuM her, you mu" scan the input differe ntly for different kinds of sensOfil. NO cOntacts and NC
M

to

4 Hi"ary Logic Operations

, , ;' ,
-

(; .., I : Bo,h .. n.on a ... 1'0 <on'uf!

So1/) Ufl;o",

->
0

" "
0

" .,. .,.


M

, t ) "''',,,''ed ,1 4

Cu. 2: On. ~o contaN ond un.l'C <un(.

~5j

, ., ."" "".
-

-. , . lr , " .,." 0
-7

Bolh Hn"""" actlv. ,to<i

HH4H H 1HH4H HH'H HHH'H H H1


1 4
0

.,.
Con"'ctor
plcl<8 up

"
~-jllu" 4.~ T~kjng oontact~

"

"

Conr. ctor
pict. up

.,.
"

Account of tho Se""'I Tn'" (LAD)


10 you for this purpos~.

arc

a~aiJablc

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 <can remit fimher. you mllSt scan !.he in put dift-"re nrly fo r diffcrent kind. of <enSOr:>. 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<XIIO the programmable controller, and in the <econd ea,e one 1'0 contact and one NC contact. In b<)1h en_Ie " a C(lntaClOr eonne<:t~d to an outpnt i, to pi ck up if hoth " '''wrs ar~ a<:ti" ated_ If an 1'-'0 contact is aClivated. (he signa! St at e at Ihe inpnt is " I ", and this is scanned directly so that the scan resu lt is " 1'" "hen the sensor i< ac li "al~d . If bolb NO contacl.'S an; acti\cated, and Al\'i) condition i. fuJfill<XI and the colllaclOr picb up.
Ifan l'C contact is act iva(cd, !.he signal Slate a( th~ input is '"0--. In order (0 obtain a , can rcsuJ( ,,[ "I" , the inpnt mUSI be negated Wh~fl seanned. In the second case, you n~~d an AND func!ion with on.... direct and 0"<: negated ;"I',n in order for the e'-'nt:<~lO r to pi ck up w hen both sensors are acrivaled

4.3 Takinj;; Account of the Sen_ Type

c.", I : 8Gt~ "'....... . .. ]\iO r ..n'",!>

E-s~

,
"
&
Q
4 .~

I
"0"

~I

E-s~

---7) H "'
I
"
1.~

c.", 1 : One ~O <o ...u .mel .. lie NC r.n._..

'"

"--J
&
0 4.2

r
"

" "'"

E-s~
"0"

,- T

->

S
"

~
&

" "'" " "'

-----... , ,"

'to

~
&
0 .3

11.5

" '"

...

"

'"

"'

0".3
~

...

"".~

"

"'

" Coo

-~

Fljtu .... 4.10 Taking Aerow" of1h< SeruorT)-pe ( ~ FBD)

'"

Memory Functions

5.1

LAD C olis

In & l&<!der diHllrwn (LAD), the memory functioIU are u~ ;n c"njunction with s"ries and ""mllel circuits in order to influenc", the siiJIpJ sate.< of the biImry op.....mds .... ith the aid oflbe n:sult of the logic o!"'rntion (R LO) lIen",rated in the C PU.

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

'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.


T he boxes RS and SR as memory functions

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<a direct the po,,"cr flow in(() !;evcral coi ls simulmnC<"lusly by ammging the coils in parallel with the help of a T-bT"II.nch (NetworK 3). All opcrdlld. '!",citied OVCr the coils rupond in the same way.l:p 10 16 coil~ can be cODne<:led in parallel.

1> 1> 1>

The midlinc output, as


The coil5 P DOd N as power flow

inl.<:rmcC; at~ buff~rs

cdg~

c,calwl\ions ofllle

1>

The boxes P~S and l>."EG ... ..die nalua lions of opC'l'ilnds
~ di~_

Midhne outputs and edg'" ",valuano!lS


clI$~

in ~tHii in sub'eqn"'nt chapt"'rs.

armnge funher eonIPCT~ in ~ries and I'arallcl eircuits after the T-bran<:h and befo~ the co;1 C'/etwor\l:: 4). You
Sec Chapter 4.1 Series 1OI1d Parallel Cirruits (LADr, for fiInhCT c1Ulmple~ ()flbe single coil.

~;m

You can usc tbe memory fimctiQllli d.,scribed in

!hi, chapl<.T;n conjunction with all binary o~r ands. There are restriction.> when using temporary local data hir. a. edge
TI,,~
m~mory

5.1.2

Set and Re.et Cull

bus.

examples shown in this ch apter arc found in function blocK 105 of the "B asic Func tiOll.>

Set and resct coils also lenninate a "mg. These coils only become "'live when power floWS

through Ihem.
Binary QPerand

prolP1lln in the LAD_Book" libmry thai >Qt, can downJOiw frQm the publisher's Web~itc (see pagc H).
For incrcmL"fIlal programming. yQU ....ill lind the program elements for me memOfy funCTions in the proaram element ca1.ll10& {with VIEw ~ OVI!RVII:WS [CI,I - K] or with L'iS[RT ..... PIW(lRAM EL~\'(Il'iT!\) under "Bit L01! i~".

i')
Binary operand

(.)
If pow.... fio",s in til", sel COIL the operv.nd O'CT the coil is set to signal '!lllt . I' If J'IOV.CT flo"'$ in the /"eSC"< coil the oJm"llnd o'er the Coil is !\:..cl to signal state 0'. If thcre is 00 power in the SCt or l ese, coil, tbe binary operand remains unaffectc<! (l-igu,.., 5.1, Networks ~ I1lld 6).

5.1.1

Slnll'eCotl

The single coil as terminator o f a I\IIlg assiil15

Ihe power flow directly to the operand located

'"

5.1 LAOCo",s

SIll> J. coli

Ii I I I~I I
N_ork2 N_twork 3

,..rwork , laCn

"'")--I 1
INOTI
CoII2

Contact1 Coil1 Contact1


Col 1 2

I
I I

I I I I

1 )--I
Coll3

-,

n n
I C

~_:~tet2

I
Coo<od.

Coo"'" {",)--I CoO,

n n
i i

CoO<

N_rwork"

l lil

"""

Coo"""
c.,,~,

I
I I

~
H
I
Ulet '

II

~ "'.
CoilS

I I I

I I

~
I
I I --, I I
I
I I

CO"

ConlaCl1 Coil1

1')--1
CO"

N_orkll

,teet2 I

c.".",

(0)--1 CoO,

N_lwork 1

H """ """"'" I I
I,
"-11I.U~

"'" 'J

c~li10 $)--1
Coil11

.,..,.., I ""'" I """"" oj CO.


Co'1 9 CoillO Coi l11

)--I
5. 1 Sin,l. Coil. SCI and Rc= Coil

I
I

The function of the set and reset ooils depends on the Master Colllrol Relay. If the MCR is IctiVlt"~l. the binary o!",rand 0\'''''' the coil is not affected. note that the operand used with a set or resel coil ;$ usually reset al STartup (complete TCSlal'l) . In SIX...:;al cases. \he signal stale ;5 fCtai ned: This dep<:nds on Ihe ,lal'lUp mode (for
Plea~

u~mple "'"8JlII restal'l). on the opeTllnd usod (for example SlaTic local daTa). and o n the oeItings io Ibe CPU (for uample fCtentive eh.alrscteri~tics).

You can a""" ge several "I and reset coils in any combioation and logelher w ith single coilo in Ihe .ame JUng (Ke\work 7). To achieve elarilY in your programming, il is advisable \0

'"

5 Memo,), Functions

)V"oup the set and reset coils affecting an oprrand together in puin;, and to u,c them only once in each ca,e. You should aho a void additionally controlling tM"Se opera"ds with a s ing le "oi l. A, with the . ingle coil. you can also arrange contact, after the bran~h and before a sel Jnd reset coil. 5.1.3 ;\-tcmor y Box

P1eas~ nole that the operand u8cd with a memo ry fuu"ti,m at startup (complete restsrt) i. usu a lly reset. In special cuse,. the signal 'tate ofa m emory box is retain ed . Th is depen ds on the 'tatnlp mode (for example warn, re.tart). on Ihe operand used (for example "alic local data), nnd on Ihe s~t1 i ngs in th~ CP U (for instance retentive char~Cleris tic.,,) .

S R memory fu n rtlon
ill the SR memory box, Ihe reset input has pri-

The functions of the s~t and ,.."et eoil are 'urnmarized in the box of a memory fun ct ion. The common binary opcI1lIld is localed m'e< the box. Input S of the box corresponds here 10 the sel coil, input It to thc rcsut "oil. The s ignal state of the binary opC1"and as,igned 10 the memory function is at o(jtput Q urthe memory function. There are two version, of the memory fiUlclion: As Sit box (res~1 pnority) and ItS box (set priority). Apart from tbe labeling, the boxes "Iso di m .... from each other in the arrnngGmc"T] t of the Sand R inputs . Binary oparand

ority. Re'~1 p riority means thal thc mcmory function is Or r~mains resct if power 1I0w~ " s imultaneously" in Ihe set input and the re,el input. The TCS~t inPUI ruB priority over the sel input (Figure 5.2, N~twork 8). B ecause the , tatcments are ex~cllted in ''''1ucnce, the CPU initially .cts the m~rnory operand hecame the Sl1 inpltl is processed fi",l , bUI resels il again Whl"l1 it process e, th~ re,ct input . The memoryopl-rand remains ""set whil~ the rest of thu program is proccssed. is an output, this bricf only u.h, pbce in the proce ss-image output table, snd Ihe (exlernal) output on the r .. le,ant output module r~mains unafTe<otcd. The CPU does nO! transfcr Inc process_image output table to Ih~ output modules uotilth" e nd o f th~ pro"'T"~m ~yc1e .
~"tli t1g

Ifthc

m~."...ory op~rand

R S ho ("

," ,
"" ,
0

"

The memory fu nction w ilh r~Sel priorily is the "normal" forn, of the mem ory fllU~tj(>n, "i ncc th~ reset ~tat~ (,ignal slate ''0'') i~ nom, ally Ihe ,afer or Ie'S hazaniou s State . R S mom ory function

A m emory function is sct (or, mor~ precisdy, Ihe b inary op<.-rand ovcr Ihe mcmory box;, ,~-t) if the sel input ha, . ignal state " 1" and th~ ro:sct inpu.t hss signsl Mate '"0". A mcmor~ fllIlction is resel if there i, a "'I"' at the resel input snd a "0" al Ihe sel input. Signal >late "0" at bOlh inputs has no effec t On thc memory function. If bolh input' are '')"' at the t>aIIl~ time . Ihe two memory functions respond diiI~"Iently, the SR memory function is resCt and the RS m emory function i. ",,\. The function ofthe m emory box depend, on the Ma,ter Controll{c1ay. Ifthc M CR i, active . Ihe binary operand of s mcmory bo" is no lon ger s fTecINl.

Tn Ih c RS memury box, the . et input ha s prior ity. SCI priority means thaI the memory function i~ or remains ,cl if power 1I0w< "'simultaneou<ly" in the ,et input and Ihe resel input. The sel input thm has priority over th e r,""ct inpu t (figure 5.2 Network 9). In accordance w ith Ihc ,e'llJcmial exe~utjon o r Ihe instruction" Ihe CPU r~scts the memory operand wilh the reset inp ut first procusscd . bUI th en sel, il again when proc,," ,ing the "et input. T he memory operand remain, set whik \he rest of the program i, processed. If the memory operand is an OlJtput, this bricf n:M:lling lak~S plac e only in th c proc cs<-imsge

'"

5.1 LAD Coils

Ne twork a Contactl

Conlactl Contact2 Memory1

D
i i

I I
0

.1

WI

r:cn
I
,

Ne twork 9

, ,,',

Cont"ct3
C<m~'

Memory2

= I
Coil1 2

I
I

fE'

Network

'"

'""

,
I
)--I
,

I
N etwork

,
Coll13

"

I
,

M. mury rl!ootion ,,-i,b latchln

T"

..
,

If Network

12

..

'[j~" : C~:14
Network 13

Conlact2

Coil14

V1

( )--I

..

"

[j"""
CO il:15

."".
Coil1 5 Contact4

- - ( )--I

"
. . ... _....

'"

5 Memory Functions

outp L table. and the (external) output on the lt rele vant output module is not atle<:ted. The C P U doe, not transfcr the proce,s_image output table to the output modules until the end of the program cyd~, priority is the exception when using th~ mem ory function , It is m.d. for example. in Ihe implementation o f a f~ult message bufrer ifthe still current fault message at the set input i> to co nti nue to set the memory func(ioo d..spile an ac knowledgement at lhe reset input Mem ory functio n wit hin
P
S~t

5.2

FBO Boxes

in FBD . the m emory boxes are used in conj unction with binary lo~,;e opemtions in ord~,. to intlue nce the 5ignal states of binary Op"Tands with the aid of the result of the logic operation (RlO) generated in the CPU.
Available memory functions arc
:>

The a>sign box for dynamic "outro!

r ung

.. The boKt'S set ,md re,et as individually projlI'mnme-d mcmory functions


.. The boxes KS and SR as full_fl edge-d memOly functioDS

You can also p lace Ii memory box within a mng , C omacts can be connectcd in series and in para llel both at the inputs and at the output (Fig"'" 5.2 Network 10) , It is also possible to lea'.., the second input ofa memory lx>x unswitched. You can a lso connect several memory boxes logethe r within one rung , You can arrange the memory boxes in series or in parallel (Ndwork II), You Can locate a memory function after" T branch orin a branch that starts at the let, power ra il Mem ory functiu n "lth (atching
In a re lay logic diagram.

.. The midline output box as intermediate buffer


1>

The boxes P and N as edge evaluations of the re5ult oflhe logic operation

.. The boxes POS and NEG as edge ev"lu"tions of operands The boxes for midline outputS and edge evaluatioru; are dis-cussed in delai! in subsequent cbapters You can lISC the memory funclions described in this chapter in conjunction w ith all binary operands, There ar~ restrictions when using temporary local data bits as edge memory b its.
The examples shown in th is chapter arc fOlind in r\lnction block YB 105 of the "Ba,ic Functions" ptojll'9.m in the "FBD _Book' libra,'y Ihat you can download from the pubhshds Web , ite (se~ page 8).

memory function is Lls~ally implem emed by latching the output to be controlled , 1bis method can also be u,ed when programming in ladder logic. However. it has the d is advantage. when compared wit;" Ihe memory box, th~t the mC1llory function is not immediately recogn izahle .

th ~

Net\1:orks 12 and 13 in Figure 5.2 ,how both Iype, of memory function, set priority and reset priority. using latch ing . The principle of latching is a simple one , The binary openmd con[rolled w ith the coil is scanned. and this scan (the conta ct of the coi I") is connecled in parallel to Ihe set condition. If G." "act f close,. CoHN energiz es and closes the contact parallel to Contacli. If Contact I now opens again. Coil14 rcmains cnergi7.cd. CoON d~energi ~es if Conta~,t2 opens . If signal i;tstc "1" is p"ent at both Can/acl] and COn/acl], power does not flo w into the coil (reset priority). This situation looks different in the lower network : If signal . tate " I" is present at both Conlac/3 and COn/acI4 . power flo"'s into ilie coil (set priority) .

For incremental programmmg. you w ill ftnd


programelemems forthe memory functions in the program dement catalog (with VIEW --> OVERVIEWS [Ctrl _ KJ or with INSERT --> Pro()RA.~I EL E.M.ENTS) under "Bit Logi c"
th~

~U . !

A SSign

n ,Ca5sign box as tenninator o f a rung assigns the result of the logic op<:rution directly to the operand adjacent to the box. If the RLO is ' 1" at the inp UI of the assign box . the binary operand is sel: if the Rl.O is "0", Ihe oper.md is rese t, The function of (be assign box depen ds on the 1\'!aslC[ Control Relay (MeR): If Ihe

'"

5.2 FBD Box",

MeR is activated. signal state "0" i, assib"'cd to the b inary operand over the box .
6ina ry oper~r>d

-l

A muober of example., in Fig ure 5.3 explain how the "" ign box works _ Nelwork t : Th~ '-'P~rand Outpull dir~~dy assumes the signal state of the operand Inputl. Network 2: You can use negation to reverse the function of the assign bo,, _

Network 3. You can d irect the RLO to ",veml boxes simultaneously by in,crting aT-branch and arranging the bo"e.' \~ith the relevant opec~mis ODe below the othec ("multiple output") . All orerands oV~c Ihe box~ , respond in the <ame way_ N etwork 4: You can in,en binary fuocl;ons between Ihe T-bratleh anu th~ lc-'TIllinating box. thu, expanding a logic operation by additional [unction boxes . You w ill find adu ilional examples for th e ,,"s ign box in Chapter 4_2 "Flinary Logic Orerations
{FBD)".

A"ilIn
Network I Inputl Network :l Input1 Network 3 Input2

..
Ou!p~ t l

I I
OlJlpUt:l

l"Putl Outputl Inpvtl


O~\put:l

I I

....

CJ

q I
OutputS

, r:l'

CJ

, "" n,
r=J

Input2

Ne twork 4 Input3 Inpu\4

L>H
O ~tput5

Output3
O~tp~t4

9,L
OUlpUt7

Input3 Output4

I I I I I I

CJ

"

I I

CJ

OulputS

- I

OutputS
Oulput6

S<t and ...1


Network 5 I"putl NetworkS

=
-

I I
OutputS

Inpull Ocotpua Inpu!2 Output7

I I
I ,

r:=J
,
i [7]

Output7

.,
,

I~

Inr()12

. "'"twork 7 Input! _ Input4

Inpu\3 Input4 Outputll

I
c

Oulput9 R
OutputlO Oulput11

"""".

OUtputtO

Output1t
Fil:u~

5.3 Ass;!!". Set and Reset (Hl D )

'"

S Memof)' Fun~Iio~
~ . 1.2 S ~I

and Rent Box

S.2.J

M em or y 8 0x

ScI Rnd reset boxes alro terminate a logk oper. alion. These boxes are a<,:tiv~I~d only woen the
rc~ult

o f the 10llie operati on going into th .. box

is

~I".

The functio n, of the set and reset boxc s arc: ~ummarized in tbe box of n memory function. The common bioary openmd is 100aled o,'er the bo" Input S of the box corresponds bere \{)!hc set box. and inpul R 10 the reset box. The SignBI mile of the binary opmInd as~ianed 10 the mC'lllOl"y function i. at OUtpU! Q of Ibe memOf)' funclion,

If Ihe RLO going inlO th~ $\:1 'oo~ is "I". Inc operand over the 'oox i~,scl to sianal ,tate "1". I r the RLO going inlo Ihe reset 'oox i, "I ". the operand o,-er tbe 'oox i5 Kt to signa.l 5tIIte ~O", If the RLO going into the "' or fe.! bo" i~ "'0", the binary operand remains unaffected. The function of the """ and reset boxes depends on th~ Mas!el Control Relay. If th\: MCR ;~ ",ti. vated, the bmary operand OVer the box i. not
RfrC ~led_

Fillure 5. 3 shoW1 'C\leTIIJ ~xamplcs of bow the sct and ",,,,,t boxes work..
Network 3: The opeJand 0ulpuI7 i, sel "'h<n the operand lnpu'l is "1". 0u1pt<17 remain. SCt wh<n l"pUll rctums to '1J1&I S\.ate ''0'',

There are two 'e!"Sion s of the memory fu nction: As SR box (resel priority) and as RS box (.", prion!)). Apar1 from Ihe labeling. the boxes also differ from .... ch other in tbe arrangement of the S and R inpUIS. A memory function is KI (or. more precisely, the blIlary operand o>"er tb.. memory box is set) when the sc. inpul is "\ """lbe resct inpul is ''0''. A memory functi on is reset when Ihe reset input is " \ " and the set inpul is "0". S i~nal state "0" at both inPUI;; has nO dfe.:1 on the memory functiOn. If both inpulS haH signal ,tate "'\" si.."nultaneously, Ibe twO memory funC1ions respond di(ftTCIIdy' the SR memory function i! reset and the RS memory funC1ion IS SCl
n

Network 6: The opel1lnd OurpUlllS reset'" hen the operand lrtpu,2 i$ "I". 0u'put7 remaim resel when lnp.<l2 rerurns to signal Slate ''0''. Network 7: You can Rmnge severa l set and boxes in any combinati oo aDd loge!her with a,ssign boxes in the >lme box after a T branch. A. with the assign box. you can a l.o pr.:lgram binary functions after the T-branch and befOTt' a sel and reSCI box.
re~et

To lICb.icve clarity in your programming, il i5 advi ,able 10 JOI"OUJ'! Ihe SCI and re"'" bo",es Bfflinl( an operand in pairs, and 10 uSC them only oncc in each ca~c. You sho uld al.., avoid controlling these operands '.nth an assign bo".
Please note that the operand ust<i wilh a sel or box is usually rc:set on sWlUp (cold re.tan or "'ann restart), In ~ial cases. the sijplal stale is reeained. This depends on the ~tarh.lp !11(lde <for instance hot TC:S!an). on rhe operand used (for e.~ampk StaUe 1~a1 data), and OD the 5ettinw:s in !he CPU (.uch as retrnti\ e "bamete,. iolics) .
re>ll:t

The functioo of the memory box d~s on the Mas!er Control RelAY. If the MCR is lIC1ive, the binary operand of" memo!), 'oox is no longer affecled . Please note thaI the operand used with a memory function i. normally reSCI on startup (cold 1"H".AI1 oc wann restart). 10 spce:ial cases, tbe signal 51alO of .. mCTl>O')' oox is retained. Thi~ <lepcnds OIl the ~1lUtUp mode (fOT imU'lnce hot restlll). on the <>pennd used (for example stalic local da! a). and "n the serungs in the CPU (such as n:'temive charaC1erislic.).

...

SH: me,nory funCllon input has priority. Reset priority means tbnt the memory func tion i. n. remains reset iflbe RLO is 'T al trn: 111.1 W>d resci inputs M~i mu!laI:twusl)- . The reset input Chen has priority o"er the sct input (Fi8U~ j.4, I\etwork 8).
r~.ct

In the SR memory box , Ih..:

Be.:au..e Ihe s!atemenl ~ are e~oxuted 10 seqllcnce, th CPU lirst .ets Ihe memory Op<:Tand b<:"HU~C the sel i"l'ut i~ I'roccs~ed r.rnt, hut ~sets it again when it prO<:e5~e~ the reset inrul. The memnry op"rand remains reset wbile Ibe re~ of the program ~ processt'd. If the memory operand is an OUlput. this brief ienmg take~ plac<: only in the proc:ess,image

"etwo'" 8
In put1

Inpull

---I'

.~O

OUtputl2 InpU!3

In ....!'"

Inp(lt4

OUlpUt13

"

"
,

,
"

~ ,
t tjlu re
~.4

Momory

Function. (FRO)

'"

5 Memory fu ncti<>n. OUlput lable, and th e (ex temal) output on the relevant o utput module r~main, unaffected. The CPU does not trans fer the process,image output table to the output modules until the ~nd of the program cycle. The memory fllnc tion w ith reset priority is the "normal" fonn o f the memory function. as the reset state (signal stale "0") is usually the safer or less hazardous state .

5.3

M .idl io c

Ou t puts

lI.1idline outpms are imennediate binary buffers in a ladder diagrJ.m or function block d iagram. The RLO valid at the mi dline QutP\l\ is sto~d in the opernnd o'er the midline outplll. This op er, and can be scanne d again at another point in (hc program, allowing you to also post,proces~ the R LO valid a: midline outpUl elsewhere in the progrMlL TI,e following b inary operands aTe suitable for iruermediate storage of binary results:
[>

RS rncm(lry functiou
ill the RS memory box. the set inpul has prior, ity. Set priority m e aIlS tbm the memory function is or remains sct if the RLO is '"1'" at Ihe sCt and

reset inputs "~imul laneously" The set input th~ "Il has priority over the re ,et input (Figure 5.4. Netwo rk 9). Bccau"e ,he statcments are e~ecut\!'d tn sequence . the CPU initially reSets the memory operand be~a "sc the reset input IS pr<><:eiSed first. then .et;; it again when the set input is pr0cessed. The memory operand remains ,et while the rest of the program is processed .

You can use lempo",r)" local data b its if you only require thc in t ermeui~te resu lt w ithi n the b lock. All code blocks h ave temporary local da\.a Static local data bits are available only with, in a fnnetio " blud:. , th ey Ston' th~ signa l , tme Ufitiltbey are reu sed, evcn beyond the block ooundaries.

[>

[>

If the memory op~rand is an output . this bricf resetting t>ikes placc only in the process, image outplll table, and th e (external) output on th e relevant o utput module is not atl"ected. Tb<: CPU doesnol trans fer the proce",imagc OUlput table to the output m odule, umil th~ cnd of th e program ~ycle .
Set prio rity is tbe ex<:eption rather than the rule. Set priority is used. for exampk, in the imple, mentation of a fault m~"age buffer if lh. still curren! fault message at the Set input is to cOn' tinue to set the m<:lDory function despilc aT) acknowle,lgem=t at the reset inpul. Memory functiun wIthin a lo gic op eration You can a lso place ~ memory box within" logic operntton Binary functions can be programme d both at the inputs and at the outpUt (Fi gure 5.4, Networks 10 and 1 1). It is al.>o pos, sihle to leave thc second input ofa memory box unconnected. 'Within a logic operation . you can a lso interconnect several memory boxes. Tbe rn~'illory boxes may be placed one behind thc other or u nder one another after a T, branch.

Momoty bits at"<; available globally in a fixed CPU,sp;: cific quantity; tor darity of programming, try to avo id nl"ltiple use of memory bilS (the same memory b its for dii~ fcrent tasks).
Data bits in g lobal data blocks are also available throughout the entire program, but befo re they at"<; used require the rdevant da, ta block to be opened (even if imp li ed tbro"gh mas> "ddres.ing).

[>

The function of the midline output dep;:nds on th~ .\1aster Control Re lay. If the MCR is acti, vated. the b inary opcran d adja~ent to the m idline output is a.signed , ignal statc "0". The RLO is then "0 " following the m id line output (that is. there is nu lunger a "flow o fpuw er"). Note: You can replacc th e "sCTatchpad m~m, used wilh STEP 5 by the tem porary local data anlilab lc in e'ery block .
OJy~

~.3.1

"lid line Outputs in LAD

A midline output i. a single coil within a rung. The RLO valid up to th lS point (the power that flows in the rung at this point) is stor.-d in the binary opemnd Over the midline output. Th~ midline output itselfha, no clTect on tbe power flow.

5.3 Midline OUlp uts

Binary ope"",.d

(. )
You can scan the binary operand Over the mid line OUtpUI al an"thcr p<lint in the program wi th NO aod NC contacts. Several m idl ine outputs can ~ progrnnuned in <me nmg. You can place a midline output in a branch that stansatthe le ft power rail . However, il must nO! ~ located directly at the power Tail. A midline output may also foHow a T-bmnch. hut may 00( tcrrninat~ a rung; the _ingle c"i l is availabk for thi. purpose. Figure 5.5 shows an example of how an in ter_ mediate re,ult is slnred in a midline output. The !{LO from thc cirellit fOlmed by Cumaer/, Con/actJ. ConluCl4 and Comacl5 i. stored in

midline output MidC oulf. If thc con d ition of the logic opcTation i, fulfilled (power Ilows in thc m idline output) and if Contac/3 is c losed. Coill6 i, energized. The J.lLO stored is u,ed in t\.,o ways in the next network. On the one hand. a ch""k i, made to .ee if Ihe condition of the logic op<:ration WlIS fulfilled and the bit logic combination m ade with Call1aCl6, and on the other hand 3 check is mHd e 1 set' ifthc condi0 tion oftb e logic opera,ion WaS no, fulfilled an d a bit com bination made with Conlael7.

5.3.2

i\lldlin~

O u tputs in F B D

A midline output is an a"ign box within a logic operation. The RLO valid up In Ih is point is stored in the midline output over the midline outpUl box

}l i dUD~ outp~b

(LAD)

Netwo-rk 15 Midline outp uts (2)

>-M--j l~1 idl


Ml d tln ~

Midl"OOI: :'__-.:~~I3ct6

~I-ict-'~I------i(

CoilH

)--I

ou' uti (HID)

Network 12 Midline ""t puts (1)


"

" "

Input2 Inpul3 Input4

Inpv~ _

,.,
Midline!

&

"
"

,
Oulpol16

Inpul5

M"" 1 " I ---f'" oo' , ~". ~ Midline!


&

3I
. :

Input?

I'" I

OutputH

I I

Figuc< S.S Midline Outputs

5 Memory Function, ory bit). This mu,1 be an operand whose signal state must be avai lable when the edge evaluation is again encoum~"'ed (in the next program c ycl e), and which i, not used elsewhere in the program. Memory bits . data bits in global dala b10cb, and static local data bits in funct ion b locks acc all suitable as operunds. The e<ige memory b it stored the "old" RLO with which the CPU last proce,"ed the edge c,-aluation. If a signal edge is now present, that i~. if the eu=nt RLO differs from the signal stme oftbe edge memory bil. the CPU corrects the 5ign~ 1 state of the edge memory b it by a~signillg il tl1e "value" of the "new" RLO . \Vh~n the ed g~ evaluation is n~xt processe<l (usually in the next program cycle), the signal Slate of the edge memory bit is the same as that ofthe current RLO (if this has not change in the meantime), and Ihe CPU no longer de t e~1S an edge.

.... klline ""tp~'

Binary op ... and

---4

11

I--

You can ~heck the b inary operand over the mid~ lin e output at auother point in the program. Several midline oulp ,IIS mayb~ programmed in one logic operation. A midline oU!put box must nOI tenninate a logic operation; tbc assign box is .vailable for this purpose. Networl<, 12 and 13 in Figure 5.5 illus!rntc how an intermedi ate r. sull is stored in a m idline ou'pUI. T he RLO from the c i",uit formed by InpurJ , Input2, {"pur3 and Inpm4 is stored in midline output Midl_ourl. If the condition of the logic operntion is fulfilled and if the signal stme uf lnput5 is "I". Olllp",16 is activaled. Tbe ,tored RLO is us~d in t" 0 ",a)lS in the nex! network. O n the one hand. a cbeck is made 10 S"e if the condition of the logic operation was fulfilled and the bit logic combination made with {npIll6, and on the oth~r hand a ,heck is made to sec if the condition ufthe logic operation was not fulfille<i and a bit logic combina_ tion made with 1"1'''17.

A detected edge is indicated by the RLO after edge t' al ... ation . If the CPU detects a signal edg~. it sels the RLO to " I " after edgo evaluation (power then flows). If there is no si gnal edge, th" RLO is "0".
Signal ,tate "I" after an edge evaluation Ihere f",re means "edge detected". Signal state " 1" i, present only b riefly, usually only for the length of one program cycle. Since the CPU does no! deleet an edge in 'he next cycle (if the "input RLO" of the edge c,'aluation docs not ~hange), it "''' the RLO back to "0" after edge evalua_ tion. P le..,e note Ihe perfonname characteristic, of tbe e<ige O\slualion when the CPU is switched on. If no edg~ is to be detected, the RL O prior to edge e,'aluation must bt; identical to Ihe signal state of th e edge memory bit when the CPU is switched On. Under certain circumstances. Ihe edge memory bit must be reset in the stan up rourine (depending on the requirc<l perfor mance and on the operand used). 5.4.1 Edgt ["aluation in LAD

5.4
5.4.1

Edge Evaluation
How Edge Ev.lua tlon Works

With an edge evaluation, yo ... de'eet the change in a signal Slate, a signal edge. An edg~ is posi livc (ri,ing) w hen the signal change, from "0" to "I". The oppos ite is re ferred to as a n~gati\' e (falling) ~d ge . In a ~ircuit diagram. the equh'alent of an edge evaluation is the pulse ~"ntact ekmen1. If th is pulse ~ontact d ement emils a pulse when the Tclay is switched on, this corresponds to 'he rising edgc. !\ p uls e from the puis. contact . lement On switching off co=sponds 10 a falling edge.
Delc~tion of a signal edge (change in a signal state) i. implemented in the progr6m. The CPU compares the CUrrctlt RLO (Ih. ,,",suit of an input ch k. for example) w ith a .lOrod RLO. If the two si gnal staleS are different. a signal edge is present.

The stored RLO is located in an "edge memory bit" (it does not neces.arily havc to be a mem-

The LAD programming Iangnage provides four differenl elements for edge evaluation (see F igme 5. 6).

'"

5.4 Edge Evaluation

P""ili"" od~e 1~ tb. I"'''"' flo..l\"egaUvo edge in th o p<lWfl" no"


I'Mirin ..I~ ..lon ,,!,onll

Edge memory b<1

--4('Jf-Edgo memory bit

Ememllil2 if the series circuit con<iSling of Comuc/4 and ContuaJ interrupts the power 110w,
You may program an edge evaluati<>n with coil a fte' a T-bmnch or in a bmnch that slans 81 the left power raiL It must nO! be placed directly at the l.. ft power raiL E d ge evaluation uf a n operand

--4(NJf--

Edge memory M
N<l:"",eodG" ora" "p<rand

- LM-'",_ --'
operand

NEG
0 -

LAD represents the edge evaluation of an operand using a box. Above the box i, the operand whos~ signal state change i, 10 hoe evaluak><1. The edge memory bit !hal Slore' the "old" signal stale from the prcceding program eydc is loe8led at input M _BIT
With the unlabeled input and the ontput Q, the edge evalnation i. "inserted" in the rung instead of a contact. If pow<'J n<>ws inlo the unlabeled inp ut. output Q emil.< a pulse at an e dge; ifno power 110w, in this input , outp ut Q i.< a lso always ,e ,et . Yon can arrange Ihi' edge ev~!u"tion in place of any contacl. even in " parallel bran~h that docs not beg in at the k fl po"cr rai l. t 'igurc 5.9 shows the usC of an edge evalnation
of an operand in Nelwork 17. The edge ev,,]ua-

Edge mC1]tory bil - , " ,,-,',"--_0 '

Youc.n pro<:css the RLO dire<:t ly following an edge evaluation . Ihat is to say. store it with a "ct coil, combine it wi th down"ream comacts. or "ore it in a bina ry operand (a so-called "pulse memory bit"). You usc a p uhe memory bit when Ihe RLO from the edge e valwuion is 10 be used els~wh">re in the progr"m: it is . '" to speak. the intermediale buffer for a detected eJg~ (the J'!llise contacl eletn ~'11t in me circnit diagram), Operands suitable a< impulse mem ory bil are memory bits, data bits in global dam b locks, and lcmpomry and static local data bits. l:dce evalnation in the !,ower flow An edge evaluatiun in the powu flow is indi cated by a coil lhat contain, a P (for positive, rising edge) or an N (fot n egative, falling edge). Above me coil i, an edge tn=ory hit, a binary operand, in which the "old" RLO from the preceding edge evaluation is stored , An edge eval uation like thi, ,ktecIs a change in the pow~" flow from "rower flowing" to "rower nnl 11 0W ing" and vice verla. The example in Figure 5. 9 shows B rositive and a negative edge evaluatiou in Network 16. II' the parallel circuit consisting of Contacl! and Contact] is fulfilled, the edge cval u~tion ~mit, a brief puIs . wi th EmemBil[. If COnlu,/2 is closed at th i' instant, J.kmory7 i, oet. Memory7 i, ruset again by a pulse from

tion in the upper branch emits a p ulse if ' he operand Contact1 change, its signal stale Irom "W 10 "1" (positi,'c edge). This puhe sets M emotyO The edge evaluation is always ~'Oabled by the direct connection of the llnlabeled inpul to the left power raiL The power cdge evaluation j, enab led by Contacll. If it is enahled with "I" allhi, input, it emits a pu lse if the binary operand Contact3 eh'mg~s its "ignal stale from "I" l<> "0" (nes"'i vc cdge).

5.4.3

Edge Ev"l,,"t;on in FBD

The FBD programming language provides four differ..,,! dements for edge evaluation (see Figun: 5.7).

The RLO afler an edge cvaluation can be dirc'Ctly procCSl;ed r<>r e~amplc stored with a set box, combined. with subsequent binary funclions. or assigned to a binary uperand (a socalled "pulse memory bil"). A pu lse memory bit is used when Ihe RLO from the edge evaluation is to he proees.ed ~lsev.h~-rc in 'he program: it is. 3' it were , the intermediate bulf~'T

'"

S Memory Funclion'

...... ,h~ ......

or,h* RLO
N"l!oll>'. <><Ix_
..r,loe IU,()

"'" ----4 """"""


p

E<l9ft memory till

----4

I--

Ibe 00>; is Ihe opmutd "'hose signal .ale clLange i. 10 be evalualed. The ~dge lTIC'mory bil Ihal holds the ~old" signal its.'e from Ihe last proa:ram cycle is 1000ated I t input M BIT. OUIpUI Q i~ "I' "hen tbe CPU detects a signal stale chmoge in Ibe operand. Network 15 ;n Figure 5.9 edgc eVBluation o f an operand , Upper edge evalua tion ros .. milS a pul ~e when opcr:lnd /"pml aces from "0" to "I" (pos";"e edge). This pulse ~u Me"'ory!. Lower edge evaluation NEG em;" a pu l", when bmary opct1ItId ,,,pm) goes from "J " 10 ''0'' (negali"e edg e). This pul~ re~ISM<,mory} when operand '"pul! i. >OJ".

P... I, I>" odx. or. n " ,,*rud

Binary op&falld

Ed~ m..-nory bit ~ M ~~$ 0 ~

<>f." .,........d

J'I'~oI"N

E,;g....."""'Y bn

~ M ~~G 0 ~

".,.,,-~

5.5
dele<:led edge. Operands suitllble as pulse memory bil~ are memory bi.s, daa bits in glob al data blocks, and .emp orary and s.a.ie IOCkl d ata bit~.
B

Blo ary Scale r

ror

An edge evalualion is nol permilted after a Tbranch, Ed"e e... lulltl(m or . he RLO An edge evalua.ion of the RLO is indica.ed by a box con.ains a P (for posili~e, ri:ii"ll edge) or an N (or negalive, falling edje). Above lhe IxIx is the edge memory bit, a binlUY operand conalning Ihe ""old"" RLO from the p rt:vioul cy<:le. An edge e"lIlualion like this de.ccrs a c hange of lhe RLO within a logic circuit from RLO "1"10 RLO "()" and Vice versa.

.ha.

A hinlll")' scaler bas One input Bnd one output. If .hc .illnal a. th .. input of the binary .scaler c hanges its Stale. for example from "0" 10 "I", Ihe ou.pu. also changes its siJPla l ~Ia.c (f igure 5,8). This (new) signal Slate is retained untillhe neXI, in our ~ xample pos;Ii~e, siJlllal state change , Only then does IhI: siJPUlI state oflhe OUtpul change again. This means Ihal half .he .npUt frequency appears at the outpUt of Ihe bi"",")' $Caler.

o
Output

o
-I,
I

The example in Network 14 of Figure 5.9 shows a positive nnd a negalive ed"e ev"IUII l ion. When the OR function eonsiSlina: of ' npUl' and btpuO is fulfilled" the edge evalUIItion cmib M hnef pulse with EmemBIIf. [f ' nput! i$ "I" al this insant. M<,mory/ is ~t_Memory' is rt:set again by pulse from m<'mBil! wh<:n!l.e AND function comprising Jnp"t~ and InputS is no longer fulfilled.

5.5.1

SOIUlion In LAD

There are many different ways of soh ing ' hi s task. Iwo of"'hich 3rt: presented below. The firsl solulioo uses mC1110ry functiotu (Figure 5.W, ~elwork!; 18 and 19). If the signal SIIle ofille operand Input_' is "I". the operand O"lpul_ ' is set (the operand MemoIY_'IS s till resel). If the signal Stale of the opcnnd 'nplll_' changes to "'0"", Memot)'_' is also sct (O",p"I_ ' is no,,' "I,. If Input_l is''\"' lhe ne>;1 lime arouud, Outp",_ l is re>K'l again (Ue",oryj is

Ed"e .--I uatlon of an opera nd


The edge evaluation of an operand is 1000ated at we beginninj of a b inary logie operation. O,~

".

S.S

Ilin~ry

S.caler

' I EdJl' ."OI"'110~.~'i\"''""'::::::=~,,:-:==:::~~=::-:'':====-:=~==::-~ Edll~ (I,. 7


'. ",.two", t 8
. dluallon In powor now
Me
ConlaCt"l

Edg9 meroory bi l

Con:.C12

11--1 1

I--"' "'---" " -Ii~


Con!acI4
1-1

(p)
Con(act!i

1f--1'

SR

0
.-J

1 )--1 - - - IIII-- ---(N )------i!!_ R 1"" "_ f7 !~. ....Iu. tion of an Opol,*nd

Edge """""'Y b.t2

01-- - -1

.'. ,I
,.

Network 15 d~ .vatuatlon of an ~'* ""

..

now l~). If Inplllj is once again . 'O~. Alemo'Y_1 IS reset (.ince Outpul_ I i, 00'" also re~el) . Now the ba$ic 5ta1~ bas heen n:a~~cd again .. lier twO input puis<:. and one output pul.e.

The .e<."(md SOlution uses the i.lotclling function (NetwQrks 20 and 21 ) eomm<)Q on ell:uil diaII1""rn . The principle is the .ame as in the tlrsl seotution c~cept thaI Ihe r,,,e1 condition - as is usual will! latching . is "zero "ctive-.

'"

N_ork It Binary scaler wllh mamory bo. .a (2 )


~m

- -'

,
R

NittWork 20 Binary scaler wilh Ialch!ng function (1 )

I :~F- ~: I -'-~-In'
""twor1< 21

"-'-' ( }--I

BInary scal ar with 1 lchfr\ll function (2) .

f-_'_11L~'~___-l"'"e- __r-______________Momo~ " C' ~(

1-'-,!""'-'i=1
n~wr'

,--_ e~ry_2 M--1

S. IO llinary Scaler E>.llIilpl ... (LAD)

5.5.2
Th~

SnlU IJo n In FBD

IlLSk , IWO

are many ditT=1 ways of sol,"in, Ihis of"hich are prescnled ~Jow.

instn.tClion JC>i is e"C"CUIW (you ""iI! find dct3.ile<l descriptions of the jump Qpe:rIIliOU$ in Chapter 16 "Jump Functions"),

Thc firsl solulion useS memory functions (Fiau re S.ll. Networks 16 and 17). If tbc sign.1 S iale of the operand InpllI is "1", lbe opt!1lnd 0 1<11'''/ is SC I (th e operand MemOly is slill re~t). If th e ~i gna l ~tatc "fthe openmd Inpll/ changes 10 "0''. Memory is also set (Ompu/ is now T1. ff Inpul is "J" the ne,,' .ime around. OlilPlil i~ rescI ag.. in (M..mOry is now 'T'). If b'pul ii once ",am ''0'', M"",,,,)' is reset (since OUtplll i~ now also ~set). Now Ibe basic stale Iu.5 ~ reached again after Iwo input pu[,.e5 and one

III our eumple. the jump label is called -bifl and i. in N~IW'ork 20. It i~ bere that the program
M

<can is resumed if no edge is dCI~ted. The actual binary scaler is in Network 19: If O"lpWO is " 0". ;1 is sct; if il i~ "I", it i~ rc~CI. This oeN. ork is proccsse<l on ly when an edge is ,klccled al IllP"tO. In ~ssence. every tltne an edg~ i. d~lecled al1npu/O, Ou/P'U() dmoges its signal rulle.

OUlput pul~.
The S<."COnd solu.ion uses an edge C'o... lualion of the operafld Inpu! (Figl.lrC 5, I J. l'eIWon:s 18 10 20 ). Ifno edge i. detected at l"pulO. the RLO IS "0" fol lowing edge ~",'alualion and Ihc jllmp

5.6

Example of II Con' e,'o r Co nt ro l System

Thc following ""ample of a functionally cxtre",~Jy simple cooveyor bell controllYltem illustrate, Ihe u.o.c ofbioary logic operations and

'"

j.~

bample ()f a C onveyor Control

S y ~\C'ITI

BIn.ry >._ler (Um) .Netwol1l 16 Binary acal8r w ith mA mory bous (1 ) Input

..

Me mory
,,~

,-

, , ,

,
R

~'M

'R
0
~

..

.~

- Mo~" , Network 17

'. ~ ':.1
".'~

0",.,.,
,~,

Binary scaler with memo!), boxes (2) Memo

'R
Q

".'. .: :" - .': :' .-

-. .... - .',.
-"

. ',"

OUIPUI

Network 18

.. dg.... v alu..tion (1)

-.. .-' ,.

19 Binary s caler with e dg e ltValuation (2)

OUlflutO
OUl putO

-<!

&

I - I

Network 20 (next n ..twor1l with jum p I. bel)

~
fieurc
~.Il

... ",., ...... . -.-.-;.' .. - ';' I


.~.

'.::

..... ..'
~~t .:":'"~

.. I

Bin ary

S c al~"T

Exomple. (FBD)

memory functions in conjunction with inputs . OUlpUI< and memory b it>. Functiouul de.triptlo n ?arts are to be transported by conveyor beh. nne craIe or pallel per belt. Th~ es'~ntial n.m~ lioll' are ,.. fol lows :

be lt' (end_of.belt) sen;;ors no longer det~ts


t h~m.

The example is programmed wilh input', outputS, and memory b it', and may be progranUlled in any b lock at an~ location. In th is cas." a fundion ",i'hout function value wa.~ ch()sen as block Si::n 3ts. symbols .'\. fe w additional signals ,upr!em~"T1 t the function al;ty of the conv~yor belt ~ontrol system:
0>

> When Ihe bell is empty. the controller req uests mOI~ pans by ;:;suing the "ready_ load'" .ignal (ready to load)
0>

\Vben the "Starl" sigl1a l is issued, the hell st~rts up and Iransports the pan, of the conveyor helt. an "end_oI _ ~lt" ' sensor (for instance a light harrier) de Ic~ts the pans. at which poim the bell motor swit ches off and trigger' The "'readyJcm" 8ignal (ready I() remove) When the c ontinue" ' ignal is issued, Ihe pan, are lran sponed f unher lltlti) the '"endAtth~ ~nd

I>

Basic_ ,1 Set' the controller to the basic <late

t>

Mati on
Swit~hes lh~
ti (ln~

belt on. ,..,gardless of condi-

po

t>

! Stop SIOP< the conveyor as lon g as the "0" sign,,!

'"

5 Memory functions gram in this Coapter can be found in a functian b lock witb block pammeters which can also be called as often as needed (for seven l conveyor belts). When programming. the g loba l symbols can ,,1>0 be used without qU()\3tion marks provided they do not contain any $p'-""ial Charac ters . If" symbol doe, contain a spc~ i al eharaNer (SUCh as an umlaut or a space), it must be placed in quotation marh. In th~ compiled block, the edi tor indicates all global ,ymbols by selling them in quotation marks . Figure 5.1l show s the program for tb e conv~yar control sy~tcm (functio[] block FC 11 ) under "Conveyor Example" in the "LAD~ Book" library that you can download from th~ publish ers W~bsite ~e pag~ 8).

is p,-.,sent (an /'-' C comact a, sensor, active")


i>

"z~ro

Light~bartier1

The pans have reached thc end of tbe belt


!>

fM"fauh l Fault signal from the belt motor (e .g. motor protection :;witc h); designed a, "zero ac tive'" signsl so tbat, for e,,"mple . wire break also produces a fault signal

We wanl <ymbolic addrc"ing, that is, the oper ands arc given names which We then usc 10 write the program. Before entering the pro-gram. we create a symboltabk (Table 5.1) cOntaining the inputs, outputs, m~mory bits , and blocks.

Program for LAD The c.~amplc is loc ated in a function b lock lhat you call in organization block OB I (,elected from the Program Elements Catalog "Fe Blocks'') for proccs.ing in a CPU.

Prnl:ram for F'BI) The


e.~ample

is located in a

fun~tion

which you

Here. the e"amp le is programmed" ilh memory boxes. In Chapter 19 "Block Param~t'-"rs", the ;;amc example is shown using latches. The pro

call in organization block OB 1 (from the Pro gram Element' Catalog "Fe Blocks") for pT<>' ccssing in a CPU.

Tabt.S.1

"

,,'

I .. .

it

iti .

'"

3.6 Example ofa Conveyor Control Sy stem

fC 11 Co"vo)nr <o~tr oJ ' )."""

Networ1< 1

L<tdP'"~

N.twork 2 PBrts
~

rud~

'o-",move

"M

'~,

~ _Lo~_N

Remo.e

I I

(,

EM- Rem- ?

(,

Basic_51

i, , " ... I :'......... .,',",' , .', ...,


Q
.- "
~
,~,';

to re"""1o

IMfalfl!1

,
I:
Continu"

..... . .' ,. . '".


,

RemovQ

N etwor~

Belt F."d~ to load R"ad\


EM_Rem_~

,~~

a""ic.J '

I I

(,

, " ,

wload
Q

,
,
,

, ,

,
Netwerk 5 Controll taR molor

'00'
lMfauH!

EM_ Loa

Ie

,
M,

'""

.. .... .. .... .. ':'-'! .. . .. ,;.;.


,
:.~r.:

... .. ., "
."
'

..

...

' .', '.!-'~


,;"~

:'01".

'':1:;

..

,"
Fig .. ..., 5.12 Sample Conveyor Cuntrol Systom (LAD)

'. ... .. ".:.' .. "


,. II:

" ;:c': ._.0"

In Chapter 19 "Block Parameter," , t:te .ame example is 8hown 11,;ng la\chcs. The prognull in lh; s Chapter can be fOlmd ;n a funCl;on block with block panun~te", which can al,o be c "lled 38 often as nccd~d (for ,cvcml conveyor belt').

a, "" L!1nlau, or a ,p~ce), jt mmt be plH~eu ill quotation marks, In the compiled b lock. the editor indicates all global symbols by setting them in quotation marh_
Figure 5.13 shows lhe c ircu it diagram fOT the COM"eyor control sys,em (function block Fe I I ) nf the Conveyor .LUilllple" p rogram in lhe "FBD_ tlook " libra,y that you can down load rrom the publisher', Website (see page 8)_

Wkn programming, t1:e glob" l ,ymbols can ,,1'0 be u.'-'<l without q L wtati on mark; providd they do not co ntain any 'p"c;al charactC1"S _ If a symbol does colltain " opecial character (such

'"

M~>mQry FunCl ion~

f'C 11 Com',

'Or

oonlNI .,'".",

Network 1 loood port.

light_ barrie r 1 Baslc_", IMfaull l Network 2

'""
-

..,
--<
-

~
n

Pam ready to remov..

load
Lig~t_barrier1

..,
,
N

~
~
n
Re~dy ~

BaSic_ 51 IMfau!tl

Network 3 Remove parts l oad


Remove BaSic_ 51
IMfau~ l

..,

, , ,

""""ve

oe

Network "

Belt reedy 10 load

Remove Beslc_",

..,

Reedy to load

load /Mfault 1

..,
,

oe
Q

Network 5 Controlling the belt motor

Remove Load Man on ISlop


IMfau~l

..,

B,, ~

moll

Figure S. 13 Sampl e COIweyor Control System (FBD)

,w

6 Move Fundions

Move Functions

The LAD and FBD programming languages provide the following: move function.:
~

The SFes ar<- 'yst<:m fun<:tions from the "tandard library Standard Library in lhe System
Fun~liun

MOVE box Copy orerands and vari"blos with elemen. tary data lyres
SI'C 20 BLKMOV Copy dat~ arca

Bloch prob'l"anl .

6.1

General

"
~

SFC 21 FILL Fill data a...,a

t>

SFC 8 1 UllLKMOV
Unintemlptible copying of daw area SFC R3 READ_ DBL Read data area from load m~mory

[>

[>

SFC!l4 WRIT DBL \Vri IC dala area into load memory


System memory ?wcess-I"",ge mput ~r><I output t..t>tcs
TUllO ....

You use the move fun<:uon;; w copy information bct"'~cn the system memory. the USer memory. and the user dmH are" of the moollies (l'igure 6.1) . Information is trans ferred via a CPU_internal n:gister that fu nclion, as int.<:nncdime storage. This register is called accumulator 1. Moving informat ion from memory to accumulator 1 is referred to as 'loading and moving from acc"m"lat.or I t.o memory is <:aUed lransferring" The MOVE box contains
Wor!<. memory

Modules Peripherat inputs

and

counter..

D~ta In data blocks

:' ait memory

,,-

Constants. pointer~

1
MOVE

.. -.
u

r' Process~ma~a.t""'llt
and output tabtes l' Bit memory

1
l
st;oct<

'I

"System memory
Fl~urc

Data in ,;"t8 btocks Wotk memory

Peripheral outputs ModutM

I
'"

6.1 Momory Att .. tUT Loadi ng a.tld Tnm,fe.rring

6 Move f unctions

both trnnsfcr paths. It mOveS information at inpul IN to accumulator 1 (load) and immediald y followin g Ihis fro m accumulator I 10 !he operand at the output (tran<fer)

FBD representahon

MOVe

6.2
6.2.1

MOVE Box
ProC l/"Sslng the M O VE B ox

'" "

,"0

f--

mIT

MOVE

Representation In addition to I~C enable input EN and the enable outp ut ENO . the MOVE box has an input IN and an Qutput OUT. At the input IN and the output OUT. you can apply all digital operand. and digital variahks of e icmentary data type (except BOClL). T he variables at input TN and output OUT can have different dala types. The bits in the data fonnats are discn ssed in detail in Chapter 3.5 Variables, ConStants and Data Types' .

'" "

0", ~

," 0

Different op erand wIdth s The operand wi dths (byte. word. doubleword) at the input and the output of the MOVE bo x may Hry. If the operand at the input is Iess than at the output, it is moved to the output operand right-j ustifi ed and is p"dd~d at the left with zeroe5. If the input operand is "greater" than the output operand. only that part o f the input operand on the right that fits ioto the out pUt operand i~ moved Figure 6. 2 explains thi, . A byte or word at the input is loaded rightj ustified into accumulator

For incremental prQ~ammin g. you will find the MOVE box in the Program Element Catalog (wi!h VIEW -t OVERVIEWS [Clrl - KJ or with iNSERT -t P ROG RA.>.t ELE.\!E}."TS ) under 'Move.

InpUl lN

, ,.)

01 ,

(n+l )

01 ,

(n+2 )

01, 01,

(n+3)

01Doubleword n 01
Word n

,
I"
24 123

,.>

'"

'" , ,.> '" '"

(n+1 l

01By... n 01
Bu"', Accumulator 1

16 115

*,
,.) ~

,
OutPUt OUT

0[7

,.) ~
(n+l )

01B yte 0 01

,''--_~'C')':c_~oJlc'_--'''c'_'c)_...::l''--_'c ' ') _ coJI '_--"cC'JI_....::JOI Dou bleword n l 'c': C ..


Figure 6.2 Moving Different Operand \\idths

'"

6.2 MOVE Box I and the ...,mainder ili padded wilh justit1ed from accumulator L
Fun~tI"n
z~roes.

byte or a word at OUlpu! OUT j~ mnove<J right-

Thl' MOVE box m oves Ih~ ;n fomlltion of th~ opcnuuJ al input IN 10 Ih~ ~d at output om. Th~ MOVE box only move~ information w h~n the coable inpUI is "I ~ or is unused. and when Ihe master colum] relay is dUncf\Pzed.
J f EN - "1" and the MCR i. ~'1lergizw, zero i. wr;lIcn 10 output OUT. Wilh "0" ut the enable inpu l. Ihe operand at output OUT is unaft~cted . MOVTi dne~ nOI1"C{XJr! errors.

can conneCI MO VE boxe~ in parallcl. When connecting boxcs in parollel. you require a coil 10 I<.-rminale the rung. , r yo ~ hav~ nOI provided for C!TOr e;-Hh,ation, a<sign B "dummy" operand to Ihe coil, for exampl~ a t~mporary local data hit. You c~n connCCI MOVE boxes in :<tri..,;. In doing so, lb.e ENO output of the p receding box lcad~ 10 the EN input orthe following box.. If you arrnnge scveflll MOVE boxes in one nono: (pafllll~1 at thc Icfl power rai l and then ~<.)(tlinuinJ; in series the boxes in Ihe uppcrmO~1 branch are proce~scd tirst. frnm Icft to righl. and then the boxes in The parallel branch from left tn nabt, etc.
You CDn fInd examples of the mO~e fUDCtioos in the: ''In>-ic Functinn.~ proa:ram (FR 1(6) orlbe "LAD_ Book" library thaI you can dnwnload from the publi~hcr's Wcb>;ile ( _ pai:" 1:1).

IF EN "I" or not wired THEN ENO:'" 1 IF MeR e nabled ELSE THEN OUT ;- 0 OUT ,-IN

.=

ELSE

MOVE bl'" In a logic circuit (FBI

ENO := ' 0

Enmplt
The cor"en!! o f input "ord l W 0 arc mm'wto
ml:TllOl)'

word MW 60.

If~ou w~m In process the MOVE box in dcpt.'Ddence on specific conditi ons, you can program binary logic ci",uits before Ihe F.N inpul. You caD conutc1the ENO output wllh bi nary inputs of olh..". u""tio"-,,; fm instance. you can arrnng~ MOVT' boxes in series, ",hcf'cby the "NO ou1put oflbe preceding bo" lew 10 Ihe EN input of tlw; followin g boA.

\.AD ... p......,talion '

f-- ---I E ENOf----1 N


FBD re-pr4I5OOtation
-

'M"OO,V 7.,'1

FN and ENO need nOI 1:><: w'",d.

,w 0-l'e''--'OU''"'. r- MW '" c,V;"'" r


MOVE
EN OUT MW60

You can find examples oflbe move functions in the "BIl!Sic Functions" progrum (FI3 1(0) of the "l.N)_l:Iook library lhool you CIUl downlood from the publ1shcr's Websi\(: (...", page S).

6.2.2

M o \ing Opt"noodl

In addition to the operanJ,j mention<,d in thi s

MOVl;

bn ~

In .. run," (LAD)
~ne,

You can arrnng'" contact:. in

and in paral -

lel before input EN and "fter OUTput Ef>.O.


The MOVE box mu~1 only be placed in a ~h that lcads directly to lbc ldi power rail. Th i$ bo1tnch can al .... ba\-e Conl&CIS before the inf'!Ul EN atld it need nol be the lOP hranch. With Ihe direct COIUlect,on 10 the left power rail you

ehapltt, you can als.o move limer and coumer value. (~ce Chapte r 7 "Timers" a.nd Chapter 8 "Counters") . Ch apl~r 18 .2 " Bl ock Functions for Data Bloch", deab with using data oper ands.
" to\i ng Inpu ts

IDo IWu IDo

Movin g an input byte Mo"ing an input word Moving all input doublc\\'ord

'"

lOJiTlg iwm the pmces!i image or tramfen+" g the pr,,"cs. image of Itw input>; is al,o pN'",i ..ible for all CPU, with tbe S7-300 and for til" ncwer CPU. "";11t lite S7-400 in the ease of the inpul bytes which lire nol JIfC>'<."n1 as an inpul module.
l<l
Muv i n~

outpun
Movinll: lin ,)UIPUI b}1 ' Moving "" OUlp~t ,,"ord Movi ng au output doublewoHI

The peripheral o u~p"IS (PO:;) M!"C u,ed for transrers to the 110, Only those add,,,>,,,, cnn be ac~~"""d Ihal are also OCCUPIed by IJO mooules. Transferring to IJO moo.luJ". \hat have a procen_image OUTpuT table sImultaneously updates tbat proce<s-image output table, so there i. no diffuenee beTween idmlicaUy addns,ed ouT_ pu!:> and peripbe!'\ll outpUts. 1\10,lnll hit memnry

QB"

QW"
QD"

MD. MWn

Loading from the p"",e~~ image or traru;~rring to the process image afthe oUlpu:s is alS'l pern,i.sible for all CpU. with the S7-300 and for !he ""'Wei" cpu. with the S7-400 in th~ ca5e of the oulpul bytes wllkb lin: not p""wnl a~ an OUlPUI module. Moving from tho 110

Mno

Movi"S a memol)' byte Moving n memory word M,,"in!j: a m~.,..,ory doubteword

Moving from and to !he bit memory ""Idre~ a"'3 ,. 1I1,,a,.~ permi<siblc. since lite ".-bole bit mem"ry;s in !he CPU. Please rIOte here the diif<.T,:nee iD b .. mctDOfY ""'" "i~c on the ~arious CPUs_

LH II

I'lD n PIWn

Pro "
O'Q. "
PQWn

wading a ~ripheal input byte Loading a pc,;phcl'lI.l inpul word Loading II periphen>! input double"ord

LWn

LD.

Moving a local data byte Moving: a local <1"1# "un.! Moving a l<xal dnla doubleword

"",

Transrerrlllt! 10. peripheral inpuI


Transferring to. peripberal oull'ul wem! Tmnsf.rrirw 10 a peripheral OUlpUl

MO'ing from and 10 the l Slack l_< alw,"ys .now~-d PiuS(: nOle lhe informaTion in C1wo.pl('f 18.1.5 '"Temporary L ....... "J D.I#~.

6.2.3

;\ \'(/\'inll Con f tunt$

PQl) "

doublev.ord
Wb .. moving in the 1'0 area you cau ao;ces~' ." diifere", cqx:rand.s depending On the dinxliou oflbe move. You 'p<.>Ct/)' LO inputs (Ph) al the IN inPUI of the MOV!:: bo~, "",I 1 0 output~ (PQs) at The OCT output.
When moving from the I 0 to memol''' (loading). the inpul modules ate acee ..ed as p<.T1phl-ra l inputs (Ph) , Only Ihe &\"ailahle modules may be addreued_ Plc,,!~ DOl. tlml diTC<:1 landing from the IJO modules Can mOye a diJfcrcn! ~lIlue than loading from Ih" input>; oelhe module "'ith the samc Iddrt.ss. While the .ilP'a! StUC5 of th~ inpuTS COlTCspunds I<> th" ,alucs II the sWl of the I'fOStanl cycle (wben the CPU updaTed the pTOee$._ image). the value. loaded din.."tl)" from the VO module. ITO the current ,'aluc>.

You may specify ~ons tanl va lu es onl y a t Ihe It' inPUt oflh e .\ 10\'E oox . \ lo,1nK constanlS 01 d~mNltary dala
Iyp~

A fu<;<l value, or conwuu. can be =fC1'T'Cd 10 An operunQ To ~l!hallCe cl~ril), thi~ constaD! no be tnlnsfc,.n:d in ,me o r ie,..,raJ dirrerem formats. In Chapter ),So4 " FI~mC'fltary Dat" lyP<-s. )OU" llJ rmd an overview ofallthe di f_ ferent forma", . ,\11 c, m<tunl< thaI can be mo,cd us ing the MOVE box belon~ 10 th~ ~Iem.ntal)' dald Iy!'-"S 'Eumple$:

Moymll a 2-dijCit hexadecimal number

-1000

MO"m~
~Io'ing

' .0
SST- 2s
TOO"g ,30

an I"'T ntJl'llber a REAL DUmbcr

MO'-mil: an 55 Illner Mo~mg a Time of day

".

6.3 System function. for Data Transfer

J\.I(lving pointu. Pointers are a special fOlro of con<tan! used for calculating addr<:SSCS in .tandard blocks . You can uSC the MO VE box to ,Wr<: these pointers in operands.
P III.O

If you use a variable w ith comhined data type, i\ must only be a '"complete' variable; oompo-

Movin g an area-internal rointcr Moving an ar<:a-<:rossing pointer

nenB of a variable (e.g. individual field or sITUcmrc component') are not permissible . You can usc tbe ANY point~r \0 define an area with absolute addre s< (sec Chapter 6 .3 I "ANY Po inte,).
ANY parameter" Ith t he St'C 83 and 84
The system functi on, SFC 83 READ_DBL and SfC 84 WRlT_DBL !Jan,mit dum be\ween data bloch present in the load and work memories . Complete data blocks or pam of data blocks arc pen nissiblc as actual block par<IIII~"\crs SltCBLK and D STBLK.. With symbol ic a<idre,>.ing, only 'completc' variables are accepted whicb are present in one data b lock; inilividual field <.>r structure compon~"Il\l; aTC not permi"ib le . Use the ANY pointer to speci/)' an absolute addressed area .

P;'tM2. I
6 .3

System Functio ns for

Data Transfer
The lollowing system functions arc available for data transfer
t>

SFC 20 BLKMOV Copy data area SFC 21 FILL F ill data area SFC 81 UBLKMOV UnintcITUptible copying of a data area
SFC 83 RF.AD_ DI:IL Read tram load m emory

t>

t>

6.3_1

A,'1Y I'ointer

t>

t>

SFC 84 WRIT_ DilL Writc into load memory

You require 'he ANY pointer when you want to .pec ify an ab.,olutc-addrc"",..d operand area as block parameter ofryre ANY. The general format of the ANY pointer is as follows : P#[DataBiock]Opcrand Type Quantity Examples: P#MI6 .0 BYTE 8 Area of 8 byres beginning with MB 16
P#DJll !.rHIX30.0 INT 12 Area of 12 ..... ord, in DB 11 beginning with DBB 30

ANY parameter f(lr the SFC. 20, 2J an d 81 These ,yst"'" functi on" each possess two parameters of data type Ah'Y Crable 6.1) . You can conned (in principle) any orerand. any variable or any absolutc addressed area.
Thble6.! Panunctc-rsfurSFC20.21 and 8 1

SFC .

'"

Paramc',r SRCBLK }1FT VAL I)STIlU<


BVAL

Iliaralion INPUT RETUR1'; OUTPUT


~m

Data TlP<'

to~t""ts, I~ripti"n ~ource

ANY
~, ,,~

orc. from which data arc t(} be copied

.. ._. . . .
'

" "'

ANY
I.'lT
AN!'" ANY

Error inlorrnati on Dc" ination to which data are to be copied Source area to be C'upi<Xl Error informatiun D,"ination to w~ ie~ t~. wurcc "rca is to be copie<! (mcl"w"{I: multipk: oopie,) S""rce orea trum whicb do'o an' to be copie<! Error infomlati on Do"ination to which daUl are to he copiod

RET VAL
liCK

RETURi\' OUTPUT INPU T RETURl" OU1T'UT

SRCIlI.K
~,

VAC

on
ANY

DSTlJLK

'"

Mov~

Function.

Pil1l8.0 WORD I Input "'oro IW 18

1'#11.0 BOOL 1
Inpul I
(.0

Example (Figure 6.3, SeN"orir; 4): Starting with memory b}1e M S 64, 16 bytes are to be copied to dala block DR 124 suning from DBB O.

Plealie note that the operand addJ"e,ss in the ANY pointer must al ..... ays be a bit add~ss.
It mllk~, ~ense to 'p"cify a constant ANY

6.3.3

U ninterruptlbl e Copylni of Data A rea

pointer when you ..... ant to acceSS a data area for which you have not declared variables. In prineiple. you t1Ul assign variables Or o)leTBnds to an ANY pIU1Imeter. For example, PIIII.O UOOL I' iii identical to'l 1.0' or the rele...ant symbolic addres .

SY$tem function SFC 81 UBLKMOV copies the content, of a source a~a (pa rameter SRC Fl LK) 10 a dCitination a~a (parameter DSTBLK) in the direction of ascending addres,es (incrtmenta.lIy). The copy funclion i. unintermptibk. crntmll the polSibtlity of increa""d res~ limes 10 imenupt . A mni mum of512 b)1<:S can be copied. The following actual partlllKten may be liD cd : I> Any vatiables from the operand areu for input~ (I). outputs (Q). bit memoty (M), and data blocks (variabks from global data blocks Or from instancc dala blocks)

6J.2

Copy Da ta

A ~a

The sYStem function SFC 20 BLJO,-IOV cop,es 'he conten\5 of a soure. area (parameTer SLCULK) 10 II destination area (parameter DSTnLK) in the direction of ascC"lldinll addre s&C1I (incremental).

The follo ..... ing actual parameters may be assigned:


c>

> Variables from the temporary local data (spec ia l ein:umstances 1I0vem the use of data type ANY)

Any variables from the openmd areu for inpUIS (I). oulpulS (Q), bil memory (~t), IJ1d da\.a blocks (variables from global da\.a blocks and from instance dau blocks) Variables from the temporary local da\.a (special cireUl11$tances govern the use of dat8 type ANY)
Absolute-addressed data area" .....hieh require specification of an A."'lY pointer

>

Absolute_addres~d dati. areas ...... hieh reqUIre specification o fan ANY pointer

I>

I>

Sf"C 81 cannot be u""d \0 copy li.mrs or counters. to ropy information from or 10 the modules (opcnmd area Pl. Or to copy system dall blocl<s(SDSs)ordaUl blocks in load mem ory(data. blocks programmed "ith Ihe keyword (,iIl",ketf).

You cannOl use SFC 20 10 copy limef$ or coun ters, to copy information from Of 10 the modules (operand area Pl. or to copy system data blockS (SDBs) . In the eaS<: of inpulS and outputs. the speci fi ed area i, copied regardkss of "hetheT or nmlhe addrt'$Ses aclUally ret"""'nce !npm or outpUt modules. Ifthe CPU does nO! possess Sf"C 8J READ_DilL. you ~an also specify. vlIriable or an ana from a data. block in the load memory as the $OUn:e ana.
Source area and destination area may nOI O\'or_ lap. I f the source area a nd the destination area are of different lengths. the transfer is completed only up 10 the length oftbe shoner ofthc twO areas.

In Ihe case ofmpuis and outpulS. the speci lled arca is copied regardless of whether their a ddre,>es ~fcrence input or OUtpuI modules.
Source area and de"ination area may not overlap. If the source area and Ihe destination area are of different length" the trarufer is completed ollly up to the length oftbe shoner oflbe
\Vo'O

areas.
flU Dala Aru

6.3 A

System fullction SFC 21 FILL copies a specified, alue (source area) to B memo\)' area (dC'Slin,li on a~a) as often as required 10 fully overwrite the de>lination area . The transfer j, made in Ihe direction of a>cendlOg addresses (inerc-

'"

6.3 System Functions for Data Transfer

SHtom functlon. ror

d~' a

I ...."'r.. (LAD)
S FC 20

Network 4. Exampl e for SFC 20 BLKMOV

"'O

1--------1'"
PIIM 84 .0 BYTE 16 -

SRCSL K

R ET_VAL

f- FW 82

L ____C'O'o'c''e'''f-- PIIOB I24 .D8XQ ,Q BYTE 16 ~ '

N.twOrk 5 Example lor SFC 21 F' '""~-,,,;C;;------' _ ntact3 r SFC 2 1

f---------1'"
P#M 80.0 BYTE 1 -

eYAL

RET_VAL

f- FW 84 Bl K f- P#OB I 24.DSXI6.0 BYTE 16

s ." .,. function. for dot"

rr~",r<r

(FBD)

N work 4. .

Exa mple

lorSFC 20 B=',',.,o',O,,-,;;-__, ,
r
SFC 20
RE T_VAL D STB LK E NO "Input2" EN SRCBL K

""".'

f--

FW82

PIiM 64,0 BYTE 16 -

f- PIIDS I24.DBXO .0 BYTE 16

Network 5 Exampl. for SFC 21 Fill

-r=CC-o'oCCo,"'-----, '
"'nput3' P#M 80.0 BYTE I EN BYAL RET_VAL BLK

f- FW84

I- Pll'DBI2"DBX18.0 BYTE 16

Figu re 6.3

Exompl~.

for SFC 20 RLK1>tOV .nd SFC 2 1 FrLL

mentally). The following actual may be assigned:

paramet~rs

"" Any variables from the operand areaS for inputs (I). outputs (Ql, bit memory (M), anI! dala b locks (variables from global dato b locks and from instance data blocks) "" Ab.oluteaddressed data areas, requmng ,pecifi~ation of an A:'iY pointer "" Variab les from the temporary local data of data type Al\Y (special circum.'tances ap_ ply)

SFC 21 cannot be u8ed to co py timers or counters, to copy information from or to the modules (operand area Pl, or system data blocks (SOBs) , In the case of inputs and outp uts, the speci fied area is copied regardless of whether the addrc" es actuall y referenc e input or output modules Source area and destination area may not overlap_ The destination area is alway, fu lly overwri nen, even when the source area is longer than the destination area Or when the length of

'"

till: deStination area is not pn integer multip!e o f !h~ length oflh. S<,lur~c area. Example (Figure 6.3, N elwork 5): The contentS (If memory byte :\lli 80 is 10 b. copiffi 16 rimes (0 dala block DB 124, heginning DBB 16, 6.3.5 RcadlnE frum l .old Mf mory

addrts>~-d data area can be ~pi:Cjf;cd as A.'-Y pointer<;, e.l. P#DB1OO,DBXI6,O nYTE 64, in lhe parnmeters SRCBLK ,md n STD LK.

The S)'>ll~-m function SFC 83 READ_DRL read. d,,1.11 from" dala block pr..em ill load m~mory, and wrile~ Ibem ;"110 II data block preBent in work mcm()TY, TI,. Conlenl> of Ihe read data block are not chtln!'e", The " lock p"r.meter< arc <k!ICribed in Tabk 6.2 . The sySlcm funclion SFC 83 READ_ DRL "penlles ill ""y"ch.ronoullnode : you trigger <he read prucC50S with _i.gnal ~<ale ''I'' on parnmClcr RQ. You may only lCCes! <be read and "ril1cn data areas again when the BUSY plInunel('f has returned 10 Ihe signal ~tM le "0". A dala hlock is "sUlI!ly rresem rwice iu the ".er memory of a CPT.:: once in load m emmy ""dIh~ parr rele"anl to proc;:ssinl!: - in work melD_ ory. lfa dat.a block has the altrib",lc Unlinh>d, it is only pn.$<'nt in lmod memory (Figure 6.4). The StC 83 READ DDL only ream alue~ from L oad m~-mnry. The initial value5 of me dala C>penInds - wbleh may difT..,- from the IeNal value~ in wor~ memory - ar~ pr<>cnt Iter~ (see also CItaPler 2.6.S "BLock Handling" lmdo;-r '" D ata b lock< oftliue/onlinc '") , Complete data block~, e.~. nn 100 or "Redpc I'", variables from dal.l blocks, Or an abwlute

lIthe souree area is smaller than the target area, tht: <O\lr"U area i< written complw.:ly infO the t.aT~< area. The <~m"inin~ byt<,:$ of the IaJKeI area are not changed l fthc !lUTee area is lar&er than I~ UIl\'<.:1 area, Ihe target area is wrinm compll'tely; the Il'maining bytes of till: 'IOUl<'C an:a ~ ignored.
~,j.6

Writin g ioto Load j\.Iemor},

The i)litem function SFC 84 WRIT _DBL run. dala from a data block present ;" work memory, and wri\cl; them intO a dall block p1'CSC111 in load memory. Th" COllu:nI~ or lh~ read dala block""" nol ebangoo. The block Jll'ram~:e", ~ de;.cribed in Table 6.2 . The ~Y>'I~m function SFC R4 WRIT_DEL operales in asynchrooous mock you lriggcrthe read proce~~ with ,ignsl !tnte "I" on paramet~r R EQ. You Illay only "C"CSS Ih~ I"I'kd and writlcn dlla!lre"" aga ;~ whcn lhe BUSY pamm~tcr ha. mumC(j 10 the signal SIale "0". A o:bt~ block i. rn.ua.lLy pll'5em twice in the us...mt:JT>()ry of a CPU: once in load memory and lhe pan relennt to proceS~lni - in work memory.lh d" ... block has the anrihute U,,/inJ:l'd, il is only pr<;~nt in INd memory (fi!o:Ure 6.4). Tho; SfC R4 WRIT DilL only !\Cad., value. from work memory. The inil;,,1 value. of the data openll1ds - which may diffe< fr"m the o,IUIII , al""s in load memory _ aT<: pr.:<~m her~

16.

6.3 Sy"em FunclioM for Data TfUlSf....

UH' memO<)' of a CPU


Load ",.
08 11

WorI< m .m
A "normal " <!all block e",.ted u''''11 th~ P'<>grImminll devicc i. p.esml tv.; .. in ' be CPL". u"'"' m~' il i. com~l.tely pt ...,,\t in lood mommy, and lhe data ,.t.ti ,. 10 prc-:.S$inS or. pre=t in the work memory. i .. the data with which lh. Pr<li1"'lJn worh.

--- --~ --'. -1 :-...:::: I -- . ~


~DB 11

~~I

DB 12
\oj>

''01

"'''

""'01

A datI t>tock ere-aled U,inll the propnm1n& devlCC 000 ,,;th l~ s(lnbut~ (/nli~W is only "",oem in the CPU', load memory. Thi. data block doe> no< occupy .... y opacc in .... memory.

"'k

'" "
",,.,,

0813

).

DB~

------DB 14

-, --'
;-~I

A data blk crealed u>1II11 the SFC 82 CRF. ... DaL. i. prne!ll tn!oad m=><><)' and if u..li1l1:~ i.IIOIIC1".. ted .00 in w~'k m<nlOf)'. A data blk ptet.enl in ""'"' rno"""Y i,lbe template ac<:ordinll to which the " .... ""ta block is c, ,ed.

. ,

... dall blk cfealo<1 U.inll the SFC 22 CRE ...T_l)fI ur SfC 8S CREA_DB i. only pre"""t in ,I>.. CPU'. ,,'on: memo, y

(lee also Chap' .... 2.6.5 "Blocl: Handling" under "Oala blocks offitoelodine""). ContplL"1c data blocb . g. DB 200 or "Archive I"", variables from da\.o blocks, or an a~lule addrcncd da1a area can be specified D$ AKY pOinters, c.lI. PIIDB200 ,DBXO.O WORD 4. in the p~rnmcte" SRCBl K and DSTBLK , [fthe SQ urce Rre~ is smaller than the targM arell. the IO~1"Cf: are. i$ written completely into the 1.9.rget area. Tbe remaininll bytes of the target area ore nol changed. If the ""urce ""'" ;.. IA/'ier than

the tatyeI area. the large! area is ..TitlC11 com plt-Iely; tho: mnainmg ~ of lbe soun;e area are ia;non:d
Please OOIC: if you wrile imo a data bIO<.:I: in load memory (if the initial values arc changed), you change the checksum of the uier progra'''.

Please also 001: thaI the load memory usuully only permits a limited number of writ e opera tion! for pny.icai rcawn . Too frequent writing . e.g, cyclic. limit.> the .ervicc life of the load
~moiY.

'"

7 Timers

Timers

The timers allow software implementat;on of tim ing sequences such as waiting and monitoring time,. the mea,uring of inler>aI" or th~ generating ofpul,e,
The following timer types an; available, '" Pulse timers o
(> (> (>

cum.' " time value, whi~b you can fetch from 'he timer in eith~T bina!)' or BCD code .

7.1

Programming a Timl'r
Gcn~ral

Extended pulse timer; On-delay timers Retenti,'e on_delay tim"," OfT_delay timers

7.1.1

Rep reseutado n ofa

Tim~r

You can perform lhe following <.>peralioru; on a tim er:


:>

You can program a timer complete as box or using: individual program e lement>. When you start a timer, you sJX'dfy \he type of timer )vu want it to be and how long it should run: you can also rusct a limer. A limer is ~b;;ckcd by 4uerying its <lat us ("T;m~T running'') or the

Start a timer "'itb specification of the lime !l.c,,:t a tim<-r

"

-,. Cbeck (binary) limer sl8lUs


::>

Cbeck (di!<i tal) limer valuG in binary


Ch~c k

""
Tlmorbn' ( i n 'h~ .x,mpl.' pulse timor)

(d igi"'l) time value in BCD

LAD .repr.. s.ntation

feD

rcpwsentation;

, ='" e

r""", 0 1"'....00
S~P ULSE

Bm a

" r=

The box ior a ' imer contains the coherent repre,enta,ion of all timer vperalions in the fo rm of funct ion inputs and func'ion vUlput, (Figure 7.1), Above the box i, the absolme 0.- ,ymbolic a ddre of 'he timer. In the bo". as a header, is the timer mode (S PULSE mean, "S tart pulse limer") . Assignments f or th" S and TW inp uts are mmullltory, ",bi le ~ssigt\mtnts [Or th e other inputS and outputs 21X' vptional Indhidusl program elcmenh in LAD You can also program a timer using individual program ckf1)~ nts (Figure 7.2). The t;mer is ,hen stmt ed via a coil. The timer mode is in the coi l (SP - start pulse 'imer). and below the evil i~ 'he ,,,Iuc, in SHIl'.'fE fmmm. defining the duration. To reSe, a timer. usc \hc reset coil, and us. an NO or NC eont " cl to check the Slams of the t;mn. Fina lly. you ean ,,,ore the current lime va lue . in bins,), in a word opcr~nd using tbe "JOVE bo" ,

,
R

'-

Kame

D",a Type Doscription


B~c

Sta n inpu'
t mro,ion of linK- 'I"'cification

" " BCO " ,=,


,w

S5TLME
B~'

Ro.<t input Curren' time ,.,.I"e in binary Curren' ,ime ,-,u uo in BCD Timer .tatu,

WORD

WORD

7.1

~inllaTi.mcr

Stan u-.- by Of>'if,-ioa: ~ ( ...... coil " 'id> lim. mock)

----{SPri

"""", ,,,
TImer Dl*and

...

R.... rim., (I ..... roil)

""""""
~

--{R}---l
TImer operarld

Ch"d limor 1100UI


("0000'..". NC """,""")
Road lime at binory ....1"" (MOVE 1>0>:)

TIme< operllrld

II

~l ,ure

7.2 Individual Elemen .. of. Timer (LAD)

--'"
7.1.2

- 'N
'N

MOVE

'NO
OUT

Digital
opet1Ind

In d lvld u l l p rog ra m elemenu In }" BD

For incremental programming, you wilt find


the limen; in Ihe Program Elemenl Catuloll (wilh ViEW ..... O VERVIEWS [CIt! - K ] or Il'o"SeJl,T ..... PROGRAM ELE.\IENTS) under 'Timers"",

You can also program a timer using individual prOllram element' (Figure ;.3). The timer is
then ~ta" ed vin a simple box cornainin& the timer mode (SP - start pulse limer). Below the 'ooll is the value. in S~ T!ME fonnal. defimng the duration. To resct a 1imcr, uSC the reset 'ooll. You ean scan the SlalUS ofa timerdir~tly OT in ne,aled form wilb any binary ;npln. Finally. you can $tore the current time vabe. in binary. in word operand Wiing the MOVE 'ooll.

Sf. rting,. TImer

A limer stans when the result of the logic oper_ allOn (RiO) c hllIIie5 before thc itart input or before the rum coillbox. Such. si&IIB1 c hanl!<' is always requ~ to stan I timer. In the cascof In off-delay limer. the RLO mUst cllange from

s..rt timer by .peciryina limo (...rt ooil wi'" Llm. rno:xIo)


Duration
Reid tIn><r (reset coil)

TImer op&ralld

~ TV "
--i

I
I

,","-r operand R

Cboook Llmer ....... (d....,. or IICpICd biuty iopuI)

11....:1 ""'" tiS bt....,. ,...100


(MOVE bo.)

~"P"Iand F I~nr.

--'"
TImer opII"'nd

=:d

ON

Me" 0"' t- DigtIaI opet8nd


' NO

'N

7.:l Incli"d",11 hl.menu ofo Tim.r (FBD)

Ti",~""

" I" to 'W '; all "Iher tim~..,; .llan when goes from .'{)" to "I".

Ib~

Rl. O

Struct ure of the <lun do n nf time >lIlu e ImeIrullly, the dunltion i> composed of the time \lIlue and the lime base: durat;on - time "1I1ue >< lime base. Thc dunuion is the tim~ durini which a timer i, "cti",-, ("timer running"), The lim~ ,,.Iu~ rcpn:scnts the numl:><. of cydcs for .... "'hich (he timeri;; 10 run. Th'" time base dcfine~ Ihe in'e...."ol al which the CPU i! to cbange the time ",,1\10 (Figure 7.5). You can,.]>o build up I dural1l)11 ohime right in

You e .... shin. limer in on~ of five diff",,.,,nl mode. (fig ure 7.4). There is. h",' C' er. nO poinl il\ (, . ing any Irvcn timer in "'. ore Ihan nne

mOO,
7,1.3
Spe<:Jf)1 ng Ihe Du n don
ofTIID~

Tb,' limer ,wopls the value bdow Ibe coil!bo . or the v:tluc 111 ;npul TV as me duml.on. You (~n $p:cil'y Ihe durat;on as COD>taol. L. word operand, n. as vKri~bl . oflype SjTJME.

Spc<:i/ying Ihe durol;on u.t Constant


SH lMEl# lOs
S5T1!lm I Om~

a ",,,r<! oJX'nmd. The .I maller the time ha,c, the mo,"" ~ccuralC the mct .... 1J uration. f or c~nmpl~. if you" lnt 10 implement" ,luraIion of one second,
)'OIl

DU!"lItion of lOs Dunmon of 1 miD .... 10 ms

c1llt make one Df tbrc(: specificalions: Timc


~~

The dU,...~l;"n;1 .pc<;ifled in hours, minules, omb and rnilli"ccolK!J. Th", range exICO<.J, from SSTL\1Ell'I OrtIS 10 Sj'l"ThfElf'.h46mirI3o.I {which corn--sponds Il> 9990 'j. )ntcnnediate valu~'"S are roun ded l>ff In 10 II". Ynu Can u,e 551'1ME '" l>' SSTII' lO idcmify II constant.

""c-

Durotion - 20()] I>:~ J)uratiOD - IOIO""~ OurohOD - 0100t,,,,,

100m. TIme base 10 It1$


on~

Timcb>o~e

Th. lasl 01 Ihese is the prcfcmd ca,e.

;" this

SIHCI/Y;"K lire " .. ration (f$ Ql"'rand or '-orioble


MW20 Won! ""erand comai!1ing the duration Variable o f dala ty~ SSTIME

T he yaluc;n the word OJX'.and mUSI corre'pond to data type SSTL"'1F (sec " Structure of the dumtioo of time "tlue", btlo""),

When Slan ing II timer, the CPU ,dop!!; the pro!!rammcd (ime valuc , The opernlin;:: .ystem upd1IU Ihe timers at fi"ed irltcrvab and indepcndendy of the uscr program, thai is. il de..:remenb lhe I1me va!ue of "II active lllJ'IeB as per the lime b",e v,'hcn 3 timer rcachc. zero. it has run d""",. Th~ CPU then ",",s th~ timer St~lL!S (oi1O"1I1 state "0" or"' 1~. dependiDi on the mode.

"" " " S],,-xr


~

\0 r.tart the-

"",or os

&art .!gnal

Pvil< ,;"""
i!l<tcndcd pul ..

PULSE

F 1:=3
=

E
b 1----=1

,
~

"
"

Ot,deloy tun<r
R.... nti'e OlI-dd.y \"'10'

S_ODT
S_OOTS

M S_OFFO'J

on:.!<l'

I"".,

I=-- '

F- r

172

Th\4I vel ..... In ace

riffle base In Bee

2. 1 3. 10.

'-0.1 .
oh~

0.0\ s

Flit"'.

7.~ o..criplion of the

!JUI in

DlII'Ol;OO

or "typc", of timer) and drops nn funher activilies "nhlthe limer i~ !'CStancd. If)'Qu specify:l dunuion of zero (0 ms or W.l6aOOOO) when Slllrting" lim ...., the limer rt'mams .ctiv~ unlil lhc CPU has processed Ike Urn.,.,. and discov_ ered Ihat the time has elapsed.
Timers are updated Bsynchronously 10 the progrom ""an. As a rosull. it it possible thai lhe time sta rns at the beginning of a cycle is different tllan al the end of the cycle. If you usc Ihe timers a1 only One point in lhe program and in the suggested order (5 ~low). \he as)'nelLIe>nous updating will prevent the O<,:~ulTCl1ce of malfunctions. 7.1 .4 R... crtingA Timer

o r with an l\T contact, The resultS of a check with an XO contact or with OUtpul Q differ according to the type of timer (~the descriplion of the timer ty~s. below), All is Ihe case ,uth inpulll. for example. I check ""th an N'C C011l11Ct produces exactly the opp<)'>ite cbcck resuh as the one produced by a che<k with an XO coma.1. Output Q need not be used at the timeT 00" Chec k.lng the timer
~lRtUI

( FI:I[

LAD: A limer is reSe! when power flows in the resct inpul or in the reset coi l (when the RLO i. ","), As long as the limer remai ns I'l:SCI. a scan with an NO oontacl Mil return ''()'' and a scan with an NC contact will return -I ~.
FB[): A timer is reset when a MI~ is present at the reset input As IODi ., the timer remain.< reset, a dIrect scan of the timer StaTUs will reTUm ''0'' and a negated ~CB n will return "I" .

TnI' timeT s:atus is aVll.ilable at output Q of lbc timer box. You can alS<) check the timer ,!DIUS with, binary function input (com:sp< .lIIding to output Q). The remits of' timer d .eck depc:l1d on the type of timer invol\'ed (8 the dC'SCription of the timer ty~. below). Output Q need not he used at the timer box ,

C h ecking the time v.Jue OUI]NIS BJ and BCD provide the timer's time valU( m binary (AI) 01' bioary-coded decimal (BCD). It i. the value 'Umllt at the time oft~ 'hecJc. (if the timer i. acnve. the time: value ~ counted from (he set value down towards zero), The value is slored in the spe<:ificd operand (tmnsfer as wi1h a MOV E oox) , You do not need to use lhese outputs at the limer box,

Reffttini of a timer Jel' Ih8t timeT and the time base l<> zero, The R in put at the timer box need not be wired,

7. 1.5

C h..:king a Tlmtr

Direct checki"g ofa time Wi/lie


The time
~'alue

is "'8ilable in binary-coded

C hN k.lni Ib timer sta tu, (LAD) The timer staCUS i. found It outpul Q of the limer oox, You C3n also check t~ limer status with an NO contact (corresponds to output Q)

dlJIWIl. and can be ~trievw;n this form from the timeT. In.oo doing, the lime bru<c is lost and i. rq,laced with "O~. The \'8luc COTI'CCsponds 10

a positive Dumber !II N T fannat. Plea", note: it il the lime value thaI i. checked. oot the duT3.-

7 TIm .....

t;on! You can also program direct checking ofa time value with the MOVE box .

diately reset. The subsequent timer check wilt fail to dett !he f""l that the timer was started. 7.1.7 Timer Box In a Rung ( LAD )

Coded c/.cck;"g of a lime value


You can also retrieve the binary time valu~ in "coded" form from t h~ timer, In this case. both the time value and the time base arc available in binary-coded decimaL The BCD value is structured in the same way as for the specification of a time value (see above). 7_1.6 Sequ ence of Timer Operations You can cOnnect conta~ts in series and in parallel before the Start input and the reset input as well as after OUtput Q. The timer box itself may be located after a Tbranch and in a braoch that is dire<otly connected to the left pow~r rail. This branch can also have contacts before th~ start input aod it need not b~ the uppermost branch . You can find further examples of the rcpr~.en tation and a!Tangement of timers in the Ba,ic Functions" program (FB 107) o f the LAD_ Book" library that you can download from the publisher's W~bs;te (see page 8).

'When you program a timer, you do not need to use all the operation> available for it. You need use only the operations required to exeeute a particular function . Nonnally. these are the operations for starting a timer and for checking the timer status.
In order for a timer to behave", described in

th is Chapter. it is advisable to obsCI'Ve Ihe fol lowing ordcr when progranuning with individual program elemenl~:
1> 1>
1> 1>

7.1.8

Ti mer Bo,", In a L-ogjc Cir cuit (f BD)

Start the timer Reset the timer Check the time value or the duration Check the timer statu,

You can program b inary functions and memory functions before the start input and the resct input!i'l well as after output Q. The timer box and the individual e lements for starting and resetting the timer may also be pro_ grammed after aT-branch. You can find further examples for the repres,:nlalion and arrangement oftimcrs in the Basic Fum,tioru;'" program (FB 107) of the FBD_ Book' library thaI you can download fTom the publi.sMr's Website (sec page 8).

Omit unnecessary clements when programming . If you observe Ihe order shown abc,,'e Illld the timer is started and reset simultaneously", the timer will start but will be imme-

'"

7,2 Pu)""Tuner

7.2

Pulse Timer
puls~

much longcr the limer would have run had it not been prc-maturely inlcnuptcd. ReHnlng pulse limer The resening of a pu4<c time hM. 'l.alie effect. and takes priority over the Slanina of a timer
(Figu .... 7.6).

SIArling a

timor

The diagram in Figure 7,6 descri~5 the charac

teristics of a timer when it tS staned as pulse timer and when il is ~t. The <kscription applies tf you o~ .... c the order sltown in Chapter 7. 1.6 "Scquence ofTimcr OpcntlOns" wilen programming with individual elements (starting ~rorc rescning ~fQre cheekina).

<D

When the signal st~I" al the timer's ,Iart inpul changes from "0'" 10 .')"' (positiye edge). the timer is started. It runs for Ihc prolilrammed dunl1ion loll long as the si gnal state althe stan input is "1 ~. Output Q supplies signal "at" 'T' as long as lhe IImcr runs. With the stan VlIlue as Ihe staning poinl. thc time value is counled down loward zero as per the lime base.

Sigu.al.nate ~I~ al the reset input ohn ac\h'c timer resets that timer. Oulput Q is then "0". The rime v.lue and the time base arC alw set 10 zero. If the ,igna] stalc 81 Ihe ""el input g~s from '" ]" to ~O" while the signal stille al !he sel input is sllli "I ". the limer remains unaffected. Signal Slale "I" at Ihe reset inPUI of an in.eli\'e timer has no cffect.

(J)

If the signal.tate at the timer's start input changes 10 '"0" before lhe lime hali elapsed, !he timer 510)"15. Output Q tben iii"'" to "'0-'. lbc time v.lue shows how

If ~ signal state at the ~pn input g0e5 from "0" to " J"' (posilive edge) while the rcsel5iillal is slill presenl. the limer staru bUI is immediately "<'set (.hown by a line in the diagram). If the timer slatu. ched was programmed after the reset. the brie f Starti!lg of the timer doos not affect !he cbeck.

<D
SIgnal state at

,1
I , ,
I

<l>

\he SUlrt InplJl Slgne l .tate at


I ha Ruel inp ul

n
0

~ '-,

I
n
I

n
I I
I

I~d<n!>:>n

f lau .. '.6 &h:tvion.l Cb.ratlmllic. ",hell Slanillj and ROK1Iln8 _ Put.., Tun ...

7 Timen

7.3

Exte nd ed Pulse Timer


~:<I ~nd~d "nl.~

"hh Ihe prognunm<:d lime \lIluc (the tim_ er IS ""retriggcred"). It can be ~slaned any number nfl imes witbmIl finol elupsing.
Reutt!.n .: M n
u l~Dd \'d

Sf.rlhl&.n

l imn

The diagram in Figure 7.7 ~nbes the belLa,'ioml charnc"tC";~licl "f Ihe IUn<:T .ncr il i. >Iartcd nnd wh en il i. re<;et. The do<;cripliun applies if you obs<';C'o'e Ihe urder ~hown in CharI"'" 7 ,1.6 ""Sequence ofllmer ~rions" when pr~nuning " 'ith individual clements (tllIn_ ing befon: rescuing befon; checking).

p ub e l imn

Thc resenin g of an extended pulse lin.e-r ha. ~ 'tanc dfcci. and take. prinrity o\'~r Ihe srnnin& ofa limer (fib'UrC 7.7).

00 SIgnal stale "1" II the timcr'~ re.;et input


"hile the timer is n.nming resets the lim<:T. A chc-ck for .illnlt .tate "1" (Iimer stal\ll') retUrns a cllc-ck result of "Q" for a n:~et timf;!". Th~ lime \"l'I!ue and Ihe time base lite also reset LO 7em.

0& When

the si,,'flill "ale ~ I Ihe timers Slurl input goc~ from ""0" 10 ' "\"' (posilin

edge). the timer i~ slarted. It runs for thc I'fUKfl'mmeu d1l11ltion. c, en " hen the si&Dlil , tale at ll1e sIan input chan!,es back 10 "0". A che<::k fur , ign.,\ StlW,' ""I"" (IUncr Slalus) rew.ns a .hc.:: k result of .. ,"" os long as Ille lime-r i, runninG'
Wilh Ihe slsn valu. a.< slanmg poinl. the li me value is c" < ,,,led down IUI"am. uro us JX"T Ihe lime base .

o o

A "I" at the n:;Ct inpm of an


er hll.~ no e ffe<:l.

; nactiv~

lim_

If the signal stule a. the stan wpul goes from "il" 10 ""I" (positive edge) " hill' tb~ Timer is running . hc timer is reSl3r1ed

If the signal ~lllle "t the start input ~oc.'$ from -0-- w "1" (po:o!iti"e cd"...,) while Ihe rest! ~igna! i. presenl , th. limer is started bUI is inunedial~ ly rcset (indical~d by H Hne in the dia gram). If Ihe limer s"'luS cbeek is programmed after Ihe "'>cI. the brief staninJI of the lim .... ~ nol aff~'CI the timc"T clled:.

0
SigrwIltate 1tI.. Start Input

a.

" -1 - -

. ,
I

0
I

-"

r- r---.

Signal ,18 1<' 81 the A.aHllnp \ll

0 ,

""" """'""
(iI"\temsl)

,
I

I I

DO /

,
I

T imer status (check 10< "1 -)

I 0I , , , IP P I ,
0
/

I I

"
I

.;-'i
I
I

I p , I 10 I

I~
/

,
I

I I
1 PtogrIJIr)ItMd dunIJon

no

7.4 On-nday Timer

7.4

On-Delay Timer
tim~r

lim e value shows the amount of lime still


r~ m" m mg ,

St.rting a n on-delay

Rescttinl;:: aD

OD -dcJu~'

timer

The diagram in Figure 7 ,g de>cri~s the beh",'i"ral characterist ic, of th~ timer aft~r it is slarted and Wh~D i\ i~ m;~t, Th~ d~'~Iip\ioD applie. if Y"u oh<eF>'e the "mer sh own m Chapter 7.1.<5 "Sequence of Timer Operation," wh= programming with indiv idual elements (starting ~fore rc;eUing be rore "h."king),

The ,"""erring of an on-delay lim~r ha, a ,talic ~ff~ct. and takc. priority ovcr the starting of the
l im~r (FiJlur~ 7.~) ,

CD

When the si,,'11al stalC a\ \h e timer's Slart input changes from "0" to " I " (posi!in e<lge), the ti mer is started. It run, for th e programmed dur"tion, Checks for sign" l state ' 1" return a ehc"k res ult of "1 .. when the tim e has duly elapsed and signal ,me "I " is slill pre,ont at the start input (ondelay) , \"'i lh lhe sIan valuu as ,t.rung point, the lime v,<l ue is counted down {,,"ard, zero as per the time b ose.

Q);6l Signal ,tate " I -. at the resc{ input reset, th~ timer wh"u,er i{ is running or not . A check lor signal s!Ole "I" (timer , taru,) then rctums a check result of "0" , ev~n whe'n {he limer is n<>l running and si gna l stale " 1";\ still present at the start input Tim~ " alue and time base arc als-<> set to uro A change in the , ignal statc a\ the reset input from ""I " to ''0'' ",h , lc , igna! ,tate ' "I " i, still pre'~m at {he start inpu1 !"" no effe<: t on the timer.

(2)

If \he s ignal state at the Hart in put chang., tium " I" 1C> "0"" while th~ timer is running. the timer SlOp" . A check for si gn al state ' T ' (tirn ~, statu,) always remms " che~k result o f " I"" in such cases , The

If the signal Slme at th~ , tart input goes from "0" w " I" (positive ~dg~) while Ihe r~,el signal i, prc&ent, the timer SUtTh, but i~ immediately re.,el (i ndic at~d hy a line in tho diogram). Ifth~ timer siarn., che~k is programmed aIler {he ,"""el, The brief SIarting of the {imer does not aff~cl the check.

Sig na l state at the Start in~t Sil/nal state at {he Reset input

TImer running
( i n l~r nal )

-, ...: ..
'., -. , :J
P'OIll'!'l mmed d"I'!'ltion

Timer status
(d1eck fer ' j ' )

7 Time"

7.5

Retentive On-Delay Timer

Sta rting a retellli\"C on- dela,' rimer The diagram in Figurc 7.9 des ~ ribcs the hehav. ioml Characte risrics of the timer after it i, started and when it is reset. The d~s,:ription applies if you oh<erv~ th~ order shown in Chap tcr 7.1 .6 "Sequcn~~ ofTim cr Opera\ions" wh e t! prognunJlling with individua l dements (Statt. ing before re scning before ch"'-'king).

Tfth~ sig nal stal~ al tlle <taIl in pul changes from "0" to "I" (positive edge) while the limer is running . the timer restarts w ith Ihe progranuned time value (the timer is ",triggered). It can be restarted any number of limes witham firsl having to run d"wn.

Re,ctting a rctcntiYc on .delay timol' The reselling of a rctemive on-d elay timer ha. a static e ffec t, and lakes priority over the starting of the timer (Figure 7.9).

Of)

the s ignal state at thc timers Slart input goes from "0" to "1" (po, iti,~ edge), \he timer i, started. It rul)S for the programmed dmmion, C\"~"ll when thc ,ig' nal state at the smn input change. back to ''0'' . When th~ time ha< elapsed. a check fo r si gn al state '" I" (timer statu,) returns a check rcsult of ,. J" ,..,gardJe" of the sig nal stale a l Ih~ Start inp"l. A check resull of "'0" is not rernmed until the limer has been res~1, regardless of the signal :;Iate at the <Ian input. With the staIl value as slartin" point. the lim e value i ~ counted down towards zero as per th~ time ha<~.

Wh~n

00 Signa l ,tat~

"1" al thc re,et input Tesets th e timer, regard less of the s ignal <tate at the ,Ian inpm. A eheek for signa l stal e "j . (timer slams) then return.' a che<:k result of "0". The time value and the lime bas~ arc al,o ",t to zero.

If the , i~'Ilal state at the start input goes fr(>m "0" to "1 " (pos itive edge) while the I\."sd signal is present, the limer ,tam;, bul is immediately r,,,ot (indicated by a line in the diagram). Tr the tim~r statu< check is programmed aftcr the reset. the brief starting of the timer ha, no effe<:1 on the check.

0
Signal stale al Ih" Start inpul S ignal stat.. ,,, the Reset input T imer running (intemal) Ttmer status (check/or " t ")

i 'l
I
I

" rl--j H o I I I , , ID ,
I I I

n
D

p 'l
I

I 0

I
0

iI
I

I I

I
I

I I 0

I
0

" I "II n
I

I I

D 0, ,
I

PM;Jt8mmftd dum /ion

Figure 7. 9 Bohavioral Characteri<tks "hen Startiog and R ~. ottinl1 an R<tenrin On-I).lay Ti mer

7.6 OfICDclay Timor

7.6

Off-Delay Timer

staned onl y when there is a ocgalivc ,,,Ige at the stan input Resetting a n off-del ay Ilme r The resetting of an off-delay timer has a static effect. and takes priority over the starting ufthe timer (Figure 7.10),

Starlin): an off_delay d mer The diagram in Figure 7.10 d~scribes the behavioral characteristics o f the timer after it is started and when it is reset . The description appli~s i r you observe the order shown in Chapter 7.1.6 "Sequence of Timer Operati"n," when prognlIIlIIling wilh individual element. (,tart_ ing before reselling before checking) .

G:xl.J The

timer starts when the ,ignal state at the timer's start input changes from " 1" to "0" (negalive edge) . It mm for the programmed dumtion. Checks for signal state "1" (timer Statu.) return a check result o f " 1" w hen Ihe signal stale at Ihe stan input is " I .. or whet! the limer is running (off-delay). Wit MIhe start val ue as staning point. the time value is counted down towards zero as per Ihe time base,

Signal state "]"' at Ihe timer's reset input whi le th~ timer is running resets Ihe timer. The check remit of 8 check for signal 'tale" j" (timer status) is then 'ir'. Time value and time hase are also .,etto zero ,

(@S ignalstate ' l at thestart iopu(andalthe reSCI input reSets the timer's binary o utput (a check for signal state . \ .. (timer status) then returns a check result of "O). If the si gna l Slatc at the reset input now ~hange ' back to "0", the timer's output once agaio goesto "l ,

(D

IflMe signal statc at IM start input change, e from "0" to "I " (po,itive edge) "'hile the timer is running, Ihe timer ;s reSet. It is re-

If the signal state at the slart input goc. from" I " to "0" (negative ~ dge) while the resel signal is pre sent. the timer starts, hut is immediately reset (indicaled by a line in the diagram). The check for signal state " 1" (timer status) then rctums a cb~'Ck reo sult of"O" ,

Signal state at the Start inpUt Sig na l state al


the Resel input

r'I
I
I
I

,.

I
I

h r
n
dUr&tlOn

h
n

r'l
nl
n
I I
J
,

Time r ru nni"l) (intoma lj Time r status


(check 10<

-" j

I I
P~m_d

I I I

In

I D I

Figu ", 7.10 Behavioral Charaoteri" ie. when Slattin g and Reninl!" .n Off Delay T,mer

7 Timers

7.7

lEe Timers

Th~ IEC timcT'< a,.., integrated in the CPU's op;.;rating system as sy,tem function bloch (SFB~),

The full"wmg timeN are avai lable on ,ome CPUs :

Outp ut .10'1 supplies the durati on o f time fur outp ut Q. "fhi, duration begins at TOOs and en d, at th~ set durati on PT, When PT has dap~cd, ET remain' , et to the elapsed tim e until input IN goes back to " .T. If input TN goes to "0" before PT elapses, output ET goes to T#O. the instant PT d ap'cs . To rein itialize the timer, , imply start it with PT '" TOO., Tim e'r SHt 3 Tl' is active in START and RUN mode . It i. reset (initialize<J) when a cold "tan i. executed.

r- SFB J TP
Pulse timer
~

SFR 4 TON On_deby timer SFB 5 TOT' OfT-delay timer


~harac t~Tis

7. 7.2

On-Oolay Timer SFB" TON


th ~

Figure 7 ,11 sbows the b<:havioral tic, ,,[these timers

T he,e SFBs arc c"llcd with an in,rance data block or uS<."d as I<><: al in813nce~ in a fun <:tion block. Yo u will fit>d the imerfacc dcscripli on for offline programming in the standard library with the name Siandard Library un der the program Svslem Funclion Blocks , You wilt fin d examples tor the calt in funclion block I'B 107 ofthe "B a,i~ runctions" p rogram in the " LAO Book" ami "FBD Book"librarie, that you can download from tb~ publi ,her's Website (,c~ p ~ge 8)

Th e IEC timer SFB 4 TON has listed in Table 7. 1,

paramNe!'s

Th~ tim ~r stan< when the RLO at its , tan input changes from "0" to "I ". Tt runs for th e programmed durJlion, Output Q ;;how. s ignnl swte " I" wh en the time has elapsed an d a. long as the si gn~) state at th~ ,t<m input remains at " I ". Iflhe RLO at th e stan input changes from "I" to "0" before th~ time has Tun out, the limN i" n;set. Th e next positive edge '""<tan, the timer.

7.7. 1

P ulse Timer SFB 3 TP

IEC ti me, SFB:3 TP has theparametNs list ed in Table 7. 1, When the RLO at the timers stan in pUl goes fwm " 0" to" I", the timer is starred, It 111Il> for the programmed duration. r~gardless of any sub"'quent changes in the RLO at the stan io ptl1. The signal Slate at OUlpUt Q i, " 1. ~s luni as the timer is Tunning
Tloble 7. 1 l'aram<ters for the TEe TlIllers

Output ET ,uppli'" the duration "ftime for the timer. This duration b eg in' at T#Os atld ends at ,c1 duration PT, When PT h as elapsed, ET remains ,cl Io the e lapsed time until inp ut IN c hwges b3Ck to ''0''. If input IN go,,, ID "0" before PT e lapse8, output ET immediatdy goes 1D T,.o(ts, To
~
r"inil i ali~c th~

limer, simply start it with PT

TItD"

SfB 4 TON is adiv~ in START and R UN mode. II is T~set on a cold sinn.

7.7.3
Th~

Off_Delay Timer S,r B 5 TOI'

~.~",;~ D ooclaratioo
~''',~'.

Ue"" ripliG1l
S,~rt

TEe timer SF'B 5 TOF hu, the parame ters listed in Tabl~ 7 1
Th~

TN

PT
RP

INPUT INPUT OUTPL'T OUTPl'T

input

TL"ID

Pulse knl(th or delay durat100 Timer >taWS Elop=:i timo

ET

TlME

signal Slate at output Q is " )" when the KLO a( the limds stan input change, from "0" to " I" . The tim~T is staned wh~nthe RLO at the ,Ian input ch~ng~s back 1D "0' , Output Q retains . igItal ,tate "1" as long as the limer ru n . Output Q is reset w hen t;, e (ime h ao clap,ed. If \he RLO ,01 the stan inp ut goes back to " I"

7.7 lEe Timers

Signa l slat.. at the Stan inp ut IN Tim.., status a ol SFB3TP Tim er statu. a of SFB 4 TON Tim er statu. Q of SFB 5 TOF

,
I

, hr ,
I

.__ t ___

,, I .
tl

, ,

r't Prrx;ramm<>d duration

f:

,-

- ,before PT has clap >cd, output ET S""s to T#Ck .

~
;m medi a t~ly

Fi ~ur<

7.11 n.haiQra! Ch"",,teru.t iol of !he TEe Tir.lcr.

before the time ha.' elapsed, Ihe time i. resc" . and output Q remain, at <>\".
Output ET supplies the duration "ftime for (he limer. This duration begins at T#O. and ends a! set dur"tioD "PT. WhCt1 PT has elapsed. ET remain , Sel tn (he elapsed tim " until input IN c han&~s b ack to "1". If in put IN goes tn '" I"

Tn rein itial i z~ the limer. sim ply art the timer with PT = T#O,. Sfl:l 5 TOF i8 active in SD\RT and RL"N mode. II i, re,~t on a cold -"art.

'"

8 Counters

Counters

Countcrs allow you to use th~ CPU to perform counting ta.,h. The counters Can coull! bDlh up and down. The counting range extends over three decades (OOO to 999). The counters a,... located in the CPU', system memory: the number of counters is CPU-specific. You Can program a counter complct~ as box or using individual program clemel\ts. You Can scI the coum to a specific initial valu e or reset it. and you can coum up and down. The counter is scanned by checking the COunter Status (zero or non-zcro count value) or the cUITem count. which you can retrieve in either binary or hinary_coded decimal.

CBU Tl '<C

box

(inltte eutnple: updown countc:r)

LAD ",presentation

C ounter op ... and

S_CUD

=, =,
FBD representation

CO

00

Oy CV_BCD

,y

=
-

'" , =
00

Counter 0 . " SCUD

8.1

Programming II Counter
"Kar.lC

ev , =
OU

Cy CV_ BCD
Q

= -

Oat>. Type Description

You can perfonD the followin g operations on a coumer:


I>

Set counter. specifying the count value Count up

OD

'>

> Count down


I> I> I> I>

,y ey ey 'CD
RP

'OOC BOOC 'OOC


WORD

Up COlmt input

Booc
WORD WORD

Reset cOlUlter Check (binary) counter status Check (digital) coum in binary Check (d ig ital) coum in binary-coded decimal

BOOc

Down Count input Set inP<i' Pre"t v"luc Reset input Current nlue in bin"')' Cum""t Ya[ue in BCD Cou:,t.". statuS
Bo.~

FIgure 8.1 COUllter III

R<p.resentallOn

assignments for aU other inputS and outpUtS are oplioIlllI. Counter boxes are available in thl"C(' versions: up-dowI\ COuDler (S_ CUD). up counter only (S_ CU). and do .... n wunte r only (S_CD). The d iffC'nces in functionality are e~plained below For incremental programming, you can find the counters in the Program Element Catalog (with VIEw ...... OVERVU'WS [Crr[ _ K ] or I"ISERT ...... PROGRA.\t ELEME~' rS) under Counters.

Repres~nlat[on

of a counler as box

A coumerbox contains the coherent representa tion of all counting operations in the form of function inputs and function outputs (Figure 8 .1 ). Over the box is the absolute Or symbolic address or lhe coul\ter. In the box, as header. is the counter type (S_CUD stands for "up_down counter"). An assignment is mandatory for the first input (CU in the example) is mandatory:

'"

8.1

Prugr~mming aCmlll!er

C"unt "J> funetlon

CoUnteroperami

(wunt ur ooil)
Coon! 00"" fun< tion (COunL down coil) Sct = lcr with ,-Ill,," uf cum;nt oount (""t counle>" "eM) with c.-.un,)

---{W)--l
Counta< o...,...,.,,:L

---{co)--l
Coo,,"'r ope"',,!,!

---{~)--I Count VlI1u.


Courrter operand

R<t Cco.Ultcr (rcM:t coil)


(1)<4

---{R)--j
COLmta, """",00
Counter ope"",d

(NO """""'t, NC contact)


R""d coun L.. bi nary valu<
( MOVE box)

t""""" ".ru,

II
MOVE

~
'"0 0"'
Digital operand'

CountS< op""md
Figur~

'" "

8.2 Individua l Ilictn""" "fa C " untor (LAD)

R~pn:"entall'... of a couot.'r u'in~ indhidual elemenl< (LAD)

tacts before the inputs and need not he the uppcrmo,t branch. You can find flU1h~r ..,.amples of the repTcscntat;on and =ngcmcnt of ~ountcrs in the "'Rasic Function," program (FB lOS) of the "'LAD_ Book" library that you can downluad from the publi'her's Website (sec page 8).
Represen tation of a counter usill~ illdi~idulll ~J~m~"L' (l'II U)

You ean also program a counter using indi vidual elemem, (figure 8.2). Setting and counting mc then done via coik The set eo un tc-r ooi I contains the counting operation (S C - Set Counter); below th~ coil. in WORD formal. is the <.:ount va lue to be u,.d to sd th~ emmler. In the coil. for count ing. CU stands for count up and CD stand s for count down . U<e the rCSI't coil to reset a counter a nd an NO o rNC ooman to ch~ck the status of" counter. Finally. you Can tTan.f,T tlte current count, in binary. with the MOVE box Counter bus i.o. M run~ (LAD) You can arrange contact> in ,.,ries and in parallel ~fore the counter inplll', the stan input and th e reset input as well as a[kr OL/tp ut Q. The counter box maybe 1,laced af\~r a T_branrh ur in a branch that is directly conn~cted to the I~f\ J>Ower rail. This branch may also havc con-

You can also program a counter u sing individual elements (Figure ~.J). Setting and ~"unti.o.g are then done Vi3 simple lxl_<~S. The set COu"t~ box contains the countT in s operation (SC = Set Counter); at inpLlt PV i. tlte count valu~, in WORD format, is the count valuc to be w;ed to gct tlt c countcr.
In the boxes for countins . CU stand. fur coun t up and CO stands for count down. Use the reset bo.~ 10 ,""sct 3 counler and a direct or negatcd bin ary function input to check tbe status of a counter.

Finally. you can tr..", k r the current count, in binary, with the MOVE box .

'"'

S Counle"

Count up r"",tion (cuun' up coil) Count d,,",'n ruuc, i"" (couo' cIowo coi l)
S ct 0"000'0< with valuo of current count (set cuunter coil w ith count)

, Counter ope<a nd --1 CO ,


Counter opo;a n<!

--1

C"

Coomer op9ran<i c oum value

~ PV SC

I
I

Re",' counter ("""" coil)


Chee ~ counte, .tatu' (d ir"'t or nC"tc-..J binary inpu')

Coullt..,,- operand

--1
CoI.l nte, "pe ran<! Count".. o.p<j,and

==:d
r-

f-

Read oount .. binary v.lue (M O VE box)

COtlfl!", operam:!

'"
'"

MOVE 0 ",

Oigital operand

'"0

Fi\:u .... 8 .3 Individua l F I. men" "f a Counter (FIID)

Connt{"r box in

logic ci,-.,u it (V8D)

You can arrange binary fun~tion' and memory fun ctioll' ~ fore 1he counter inpU(s, 1he start in put and the reset inp ul as "el l as after oolput Q. Thc counter box and the individual e lements for counti ng, settin g a countcr and resetting a counter may also bc pla~ed afler aT-branch. You can fmd rut1her examples of the represen tation and arrangement oI counters in the "Ba"i ~ Function s" program (FB 108) of the '"FR D_ Book'" library that you can download fom' the pub lisher" Web , ile ('co pago 8). Sequence of co unt in g
op ~ra tlon s

{he coon1~r to it, initial count. down conn lin g, and checking lh~ "oumer stalU,. Tn order that a counter's behavioral characteristics ~ as descrihcd in th is chapler, it is adv isab le to ob,erve the fnllowing ordcr when pm gramming with individual program dements:
I> I>
[>

Count (up or dnwl1 in any ordcr)


S~\

cOunter

Re>er conntcr Check count Check countcr ,tatu,

!> I>

When p rogramming a cou nter. you do not need to use all I ~~ operation_ available for that COlm!cr, The operations requ ired to carry oUi the desi red functi" ", ore enough, For cxampk , to program a dmvn COumer, you need only program_ the operations for setting

Omit any ind ividua l e lements that are not required , if countiug , setting. and resett ing of thc emmtor take place "simultaneously" when the op<:ralion, arc progranun ed in tbe urdC'" shown, tbe Count will flfSt be changed accordingly before being reset by the re set operation wbicb follows. Tbe ,ubsequ~nt cheCk will therefor~ ,h"w a count of zero and counter statuS "0". If counting and ,etting takc place "si mu ltaneou,ly" when the operati ons are pmgranun ed

'"

M.2 Selling and Resetting Counters contact will return a check resu lt of "" 1". Reset_ ting a counter sets its count to "zero", The counter box's R input ne~ not be connected.
R e~ettin g

in the order shown, the count will fi t sl be c~anged accordingly before being set to the programmed count value. which it will reta in for the remainder of the cycle.

The order of the operations for up and down count ing is not sign ificant.

cou n t ers (FB D)

8.2

Setting and R ese tt in g C ounters

Settin g countH.
""{l"

A counter is sct when the RLO changcs from to '"1" bcfore set input S or before the .et coi l or set box, A positive edgc is a lways required to sci a counter,

A cOunter is reset when a ""I" is present atlhe reSet input. Then a direci scan of the counter status will return "0" and a negated scan will return ""I"' , Reselting a counter sets its count 10 "ze ro"' . The counter box's R input need not be connected.

8.3

Coun ting

" Set counter"" means that the counler is SCI to a stnning value. The va lue may have a range of from 0 to 999 . S p eci fyIn g t h e conn t I' alue When a counter is set" it aSSUmes the value at input PV or the value be low the set coil or sCI box as count value. You may specify the couni value as constant, word operand. or variable of type WORD.

The counting freque ncy of a eount~.,. ;s determined by the execution time of your progmm! To be able 10 count . the CPU must detect a change in the State oflhe input puhe, that is, an input pulse (or a space) must be present for at least one program cycle. Thus, the loug~'" the program execution time. the lower the counti ng frequency. U p c ou nti ng
A counter is counted up whcn the RLO changes

Speci!5'j"g the COllm \'a/ll" os COnStom


C#l00 W#16#0 100 Count value 100 Count value 100

The count value comprises three decades in the range 000 to 999. Only positive BCD values are pcnll issibl~; the counter cannot proce ss negative values. You can use C# or Wll 1611 to identi fy a constant (in conjunction with decimal digits only).

from "O"to "1"lJ.efore the up count input CU or at the up count coil or box. A POSilive edge is always required for up counting. In up counting, each positive edgc incremeuts the count by one unit until it reaches Ihe upper range limit of 999. Each additional positive edge for up counting then has nO furth ~.,. eITect. There is no carry. D own co u nting A counter is counted down wilen t~c RLO changes from ""0'" to "1" before down count input CD Or at the down count coil or box. A positive edge IS a lways required for down counting. In down counting. each pos itive edge decrements the cOunt by one unit until it reaches the lower range limit of O. Each subsequent posit;ve edge for down counting then has no further effect. There are no negative counts,

Speci!5'j"g the coum value as operand or ,""ri_ able


Word operand containing the Count value ""Count value!"' Variable of type WORD Resetti ng counte rs (L A D ) A counter is resel when poWeT flow. in Ihe reset input or in the reset coi l (wben RLO ""I'" is present) , When this is tbe case. checking the counter with an NO contact will resuh in a check result of "0". and checking with an NC MW 56

'"'

8 Counters

Di(f<'rl'nl cnunler boxes


The Editor boxe.:
pr\>"idc~

three dIfferent couDler

made ., a;lable by this operation i~ lh e one which is current at the time the cbeck iJ made .
The "aloe ~ 5Iored in the spec;fled OjX:TlInd (transfer as " ith a MOVE box). You nocd nO! .,,i!ch tb"", nutputs at lhe counter box.

Up/down counter

Up counler

ll<:>WD countcr
These coumer be:>:e. difTeT only in Ihc Iype and numlx,. OfCOIlnler inputs. Whereas S_CUD ha~ inputs fOT both eounl;ng directiOtU, S eu has on'y the up COllnt mput and S_CD only the down count input.
You mIL'! .. I w~y~ connect the 1i!'11 U:P\lI of .. COllnter be:>:. If you do nol collllOC, the second ;lIPLlt (S CD) o n S cun, Ihi , 00:>: wi ll lah on the same chBracleri~lics as S_CU.

DI1'eCI eh<'<"king of the

"""m

The COUIlt i. a vailnble In binary, Bnd can be fetched from the counter in this furm.. The value correspond.. In K pasn; ... number in DJT format Dire<."1 ched:i1l ofa counl can also be progm:nmed with. MOVE box.

Cod<,d d ,,,d-;n8 <>{llle counl

8.4

Checking a Counter
count~r

You can also fctcb the binary count from the in "coded" form. The binary-coded deeunal (BCD) valuc i~ slTUcNrffi in the ~ ";,y as for srecifying Ihe count (sec abo\'e).
C01.J"IleT

Chccklnj;\ the

,talUs ( I.AD)

11,c counter "T atus i. al OUlpul Q ofthc "ollnler box. Yon can also check !he counter statu." ith
an NO colllaeT (COfTCS.pooding :0 OUtput Q) or an N'C COIlUOel.
Qu tput Q iJ "1" (power n ows from the OIlTJlut) when the ~um;nl count is i'"C"lcr thnn :zero, Output Q i ,~ "0" if Ihc C"ITent count i~ equnlto zero. O\IlpuI Q does nol need 10 be connected at the CO\lnto;-r box.

8,5

I EC COUill t rs

The IEC count= Iffe integrated in the CPU operat"'& ~y'1em a~ system func tion bloc~ (SI'85). The folluwing CO\Jnl~n; are ava ilable in Ihe appropriate Cl'Us;
~

SFROCTU UpcounlCT

:>

SFB I CTD
Do"'n Cnunter

C b N"kinll: the counler

~IMtU1

(FUrl)

The counter ~I~ I U~ is at output Q uf lhe cour.I~T 00:>:. You c~n al ~o check the coun ter "ants directly (correspond . to OUlpul Q ) wilh a birutry function input, OT;n negated form. Output Q is "1- wben tb~ current count ;s great .... than 7.ero. Output Q is "()" "h~n tbe cur n:nl count i~ equal In ~~ro. OutPUt Q ne.:<inol be cnnncc\C<I at ,he counter h<J~.

.,.. SFB 2 CruD


l:pldown cuunter Vou eau call these SFB, with an in' tanee dMta block OJ" use thern lOS local inst.;wccs in a function block. You will find the tm~"'face de""ript1On fOT offi lnc pro;:rarnminll on stan dard library Slandard Lihrary under Ihe .sYstem F,are/ion 810.:1:.$

program.
Ch ..ddnll'h~ fUUDI valu r (L,\J) aDd FRD)

OU' PUI8 cV .. nd CV_BCD malo: Ihe counler's current count availablc in bmary (CV) or in binary-cO<lw <iedrnnl (BCD). The count va lue

Yuu will f",d samp le calls in function block FB 108 of tbe "Basi~ fUDClions" program in the "LA D_ Book" and "FBD_Book" libmie~ thaI .'00 can downlOftd from the publishc-r's Weh.ile (see page 8).

8,5 IEC Counters

8.5.1

Up Coumer SFB 0 CTU

lEe counter SFB 0 CTU has the parameters listed iJ, Table S, I , When the sisnal state at up count input CU changes from "0" 10 .. \" (positive edge), the current count is incr<:mented by I and shown at output Cv. On the I1rst call (with signal state " 0" at reset input R ). the ~ounl corresponds to the default value at input pv. Whcn tbe count reaches the upper limit of 32767. it is no longer incremented. and C U has no cffe~1. The count value is resel lO ~ero when Ihe signal slate at r<:set input R is "' I", As long as input R i< "I", a positive edge at CU has no effect, O utpul Q i. "1 ,. when the value at CV is greater than or equal to the value at pv. SFB 0 CTU executes in START and RUN mode . It is n;set on a cold ,tan,

The conn! is set to default value PV when load input LOAD is " I", As long as input LOAD i~ " I " . " positi ve edge at inpnt CD has no effect. Outpnt Q is "1" when the valne at CV is less than or equal t<1 zero.

SFfI I

exccutcs in START and RUN mode . It is reset on a cold s tart. Up/do wn C<1untcr Sn3 2 CTUD

crn

11.5,3

lEe counter SFB 2 CT UD h as the paramcters listed in Table 8. 1. When the s ignal s tate at up count input CU changes from "0" to " 1" (positive edge), the count is incremented by I and s hown at output CV, If the signa l state at down count input CD changes from "0" to "I"' (positive edge), the count is decremented by I and shown at output Cv. Ifboth inputs show a positive edge, the current count remains unchang~d,

8.!;'2

Down Counter S}"B I CTD

ICC counter SFB I CTD has the parameters listed in Table 8,1. When the signal state at down coun t input CD goes from "0" to "1" (positive edge). the C"rrem eo ...n! is decrementcd by I and shown at output Cv. On the firs t call (wi th s ignal state " 0" at load input LOAD), the CoUnt corresponds to the default "aluc at input pv. When the curren! conn! reaches the lower limit of -32768. it i. no lo nger de~remented and CD has no effect.

If the emn:nt count r~aches th~ upper limit of 32767. it is no lon ger incremented when there i, a positive edge at count up input Co. CU thcn has nO further effect. If the currcnt count rcach~s the lowcr limit of 3276R. it is nO l ong~r decremented when there is a positive edge at down connt input CD. CD thcn has no
e ffe~t.

The count is sct to default val"e PV when load input LOAD is "I'", As long as load input LOAD is " In, positive signal cdges at the twO count inputs have no effect

Table 8.1 P3nmetor< for the lEe Counter<

,;

"

g Counters Function des crtpt lon Pans are transported on a conveyor bell. A light barrier detects and counts thc pat1s . After a set number. the counter sends the Finished 'ignal. The cOunter i. equipped with a monitoring eircu;t. If the s ignal StalC oflhe light barrier does not change w ithin a spec ;fied amount of time, the monitor sends a signal. The Set input pass~s the starting "a lue (the number 10 be counted) to the counter. A posi_ th'e edge at the li ght barri er decrements the counter by one unit. When a value of zero is reached, lhe countCI>< sends the Finished signal. Prerequis ite is that Ihe parts be arranged singly (at intervals) on the belt The Set ioput also SetS the Active signaL T he controHer manito" a signal state change at the light barrier in the active .tme only. Wh en COUll1ing is finished and thc last connted item has exited the light barrier. Ac!il'e is reset.
In the active state. a positi,c edgc at the light barrieT starts the timer with the tim e value Dur(1tion 1 ('"Dura I") as retenti,'e pulse timer. If the timer', start input is processed with "0" in the ne;<t cycle, it .till cont inues to run , A new po,iti,. edge "",triggers" the timer. th,t is.

The count i, reset to uro when re.,et input R is "1". A~ long as input R is T. positive si!>Dal edges at the two cOunt inp uts and signal ~tate "I" at load input LOAD have no effect. Output Q U is "1 " when the value at CV is greater than or ~"<Iual to the "alue at PV. Omput QD is "1" when the value at CV is les, than or equal to zero. SFD 2 CTUD cx~"<:uteS in START and RUN mode. tt;S TCse! on a cold stan .

8.6

Parts Coun ter Exam plt'

The examples illustrates the usc of timeN and counters. It is program med w ith inputs. ompms and memory bits so that it can be programmed at any point in any b lock . At this poi~t. a function witho"l block parameters is used: the timer.; and counters arc represented by complete boxes. You will fwd the same example progmmmcd as a function block with block param_ eters aod with individual clements in Chapter 19 "mock Parameters",

T_ht.8.2 S)'mbol Table for the I'.n, Coon,..,. Examp le

8.6 rCSlan$ il. Th~ nexl positive edge to res.an th~ timer i~ generated when the light balTier signals a !legnt iv~ edge . The timer is Ihen staned with the time va lue DI/ralion] ("Dura2'). I f the hght banier is now eo'ere<! for a period of .ime eJCedi na Durul or free for a period of rime e xceeding Dura]. thc limer TUns down and signal F,wff. The lim time II j, activaled. 'he limer il ~tarted wilh .he lime value D"ral. S llI n. ", sym bols

P."" CouJller fua.mpl~

We wanl symbolic addressing. Ihat is. the operands are assigned namc~ which arc then used for progranuning. Betore ent~.,.;"g Ihe program, we create It symbol table (Tpb le 8.2) containin ll the inputs, outputs, mentory bi,s, timers, COUnters. and bloch. !' roarl m The prolP1'm is located in a function lhal you caU to the CPU in 0'1l3niza.ion bl""k OB I (tclec ted fro m the Progmm Illcmento enalog underFe Blocks"). During programminll, the a lobal ~ymbols can KI..o be u,ed with<>ut quotation ma"" provided Ibey do not contain any special ChaJ1lClcrs . If a symbol contains a special c haracler (an Umiaul (lr a ~pace. for instance), il mu.~1 be placed in qU(lIHli<>n marks. In Ihe C(lmpiled block, the Edilor sho~ a ll g lobal symoo ls wilh quotalion mllrks Fillurc ~ . 4 lind Figure 8.S show~ the program for the pans counter (Function Fe 12). You can find this program in the Conveyor Example pr<!ltf"8.m of .he "LAD_8ook and "FBD_ Book libraries , hat you can download from li>c publishcr"s Wcbsile (sec page 8).

The Sel signal aClivales Ihe CountU and . he monitor. Th e light barrier comrol.~ the counter, Ihe Uc'I\~ .I a.e, ""lcclion of the time value . and Ihe Slan ing (rctriggering) o f the mo",,,,ring lime vi .. posilive and n~galive edgC!!.
Evalull!ion of ,iIc posi.iv" and neaalive edge of the h g}1! barrier is required often. and temporary local data arc suitable as scnnehpad memory. Temporary local dalB are block -local variables: Ih ey arc declared in the blocks (not in Ihe symbol mble) . In the example. the pulse memorybils used for edge evaluation are stored in temporary local data. (The edge memory bits requ ire their si gnal sta'e" in the nexI cycle as well. a nd mustlbe..,fore nol be tempo"'ry local data.)

'"

x Counters

fR'

,
lbarr1

Network 1 Counter cont,ol

"'""' S_ CD
CO

Finished

~,

,
R

c' tCV_BC D

NOTI

( )---j

Quanllty -

""'"-'
N4twork2

"

I-

, ~
~

~
I

'" "
EM_ l B_ N

"" ~

Netwol1< 3 Select duration

lbarrl Du," 1 lba,,1


Dura 2

MOVE

#t BOOl

'" '"0 '" '" '"


00;
MOVE

)---j
III Durali<ln

'"0 00;

III

D u,~ tlon

N_o,k4

~
~

~
c'

I"

'M"
Fi\:ur. 8.4

""

IR

#I Duration

Pro~nmi""

fuample for a PlUb Coun{o. {l..AD)

8.6 Pam Counter Example

Fe 12

e" un '~r

t on",,1

Network 1 Counter control

Count
cv-

L barrt
5..,t -

CD

QuantltY:-=t';V~...:O:V:,'o'-9J-=_-<i':'":"M='j : Q Ackr>owl R _
Network 2 Activate monitoring

Dural

Lbarrl -<j"
Dura2
Network 4

,.

-b_-''''J------~L_J-'[~~J

Monitoring circuit

Active Figure 8.5 Prognunrning Example for a Pons Counter (FBD)

'"

Dilila] fUDctio""

Digital Functions

The digilal funCliuns procns digital values pre. dominantly with Ihe data types INT, OINT and REAL, ~nd thus extend !he functionality oflhe PLC.
TIle c(l nlpu l50n fu n.... llo ns fonn a binary U"sult from the comparison of two values. They lake acrount of the data types u\'T. DINT and REAL.

Vou l.ISC lhe a rilhmNk fu nctions 10 make cal. culations in your program. All the basic arith. melic functions in data types INT. DINT and REAL aU" avail ab le.
The m athem atica l fu ncd ons extend the calcu-

09

Com pariso n F u nctl ons Comparison for equal to. nOI equal 10, grealCT than. greale.- Ihan or equal to. less Ihan. and less Ihan or equal 10 A rithmelic F unCII(lns Basic arilhmetic functions with data types INT. DINT and REAL i" blh .... m atlc hl F un ctio n, Trigonometric funelion,; ;n"o:\"sc lrigon..... m"'lric functions: squaring. squ~.rool eXU"8ctioll, cxponentiation. and '\lia. mh"" Con""" ion Fu nc tionl Conn'\"l;ion from l>o'TID INT to BCD and ,'ice ,.....1"~a: con"ersion from DINT to REAL and vice, et$II with d, fferenl fonDS of rounding: one's complemenl. negation. and absolutc ."alue gcnerution Shift Fu nc tio ns Shifting 10 left and right, by word and doubkword, shifting with correct sign: roulling 10 left and right Word L ogic A}.'D. OR. exdU$i\'e OR; word and d oub1eword combinations

10

lati cm possibilities beyond the basic ari thmetic to include. for example, trigonOmet. ric functions.
funclion~

II

Before and after p<'rfonnina; calculations. you adaptlhe digital values to the desired data typo: using the con,tnlo n fun .... tions . T ht . hlft fun .... Uo u. allow juslificaLion of lhe contcnlS ora variable by shifting to the right or left. Wi!h " 'o rd l\lik. you mask digital '"llues by targetina; individual bils and ..... lting them 10 "I" or "0". The digital logic opc:ralions work mainly Wilh values slored in data blocks. Thesc can be glo. bal data blocks Or inslanee data block s if slat;c local datll are used. Chapter 18.2. "Block Func. lions for Data Blocks". shows how to handle data blocn and gives the methods of address. ing dIIt. operands.
IJ

12

14

192

9 Comparison Fuoction.

Comparison Functions

The comparison fum:lIOIlll cOtnplll'e t"o digital variables of data type INT. DINT or REAL for equ;ol to. not ~quallO. gr~at~r than gr~at"r than or equ~l t(l , I~," thllIl, Or less than or ~qual to. Th~ comparison rC"Uil is then a"ailabl e os binary va lu~ (Table ~.1).

compan~n ~tunds

performed (CMP -I. for imt.anl'e. for th~ compari.on of tWO IN,. numbers for equal to) .

You cnn arrange a comparator in a rung in plac e of a conta~t. The unlabclod input and lhc unla ~led output establish the conne<otion 10 the other (binary) progrdIIl clcmems.

9.1

Proce5sing 11 C lilUplIrison Function


to C-T)
CMPnl

Co,nl'Arl'OD .... , (," eumpl<; """,pariSO" for equo!

LAO 'OpAls"ntation:

='"' '"'
- 'N' 'N'
R~presentAtiuD

The "alue, to be compa~d are pt Inputs IN I and I>I2111Jd the cornpari~n re~uh is the output. A su~ccssful comparison is equivalent to a elo.ed Contact ("pow ..... nows through the comparator). If the comparison i~ nut suc~e&~' fu l, the comact is open. The <;oml"amlOr'~ out pul ",U$t always be imerccmncctod.
R~p ~$~ nl.tlon

FRD

CMP_al

The bolt for a comparison has two inputs, IN 1 and 1>12. ""d 1m unlabeled binary output. The "header" m the box idcnlifie!> the CQmparison performed (eMP - I, for namplc. stands for the compari.on of two J1'o.'T numbcn. for equal
(0).

LAD

In addition to the (unla~lcd) binary input. the bolt for a comparison function has two input;;. IN I and fN2, and an (unlabeled) binary output. The Mlleader" in tbe box identifi~sa cnmparison operation (CMP for compare) pod the type of
TobIe ~ .l (h'c'Ivicw of the ComparilOlll'unctio""

The vuluc5 \1,1 be compared are at inputs IN I and IN2 and the result of the comparison;" at the QUtpUt . Ifth~ cOnlpariwn is ~u= ful, the comparator output sho.",.~ sianaJ state "I"; <}lh o:rw..e, it is "1)". It mUSt always be intercon neetod.

,.

"

'"

\l

Comparison Functions

Uata types T he data type of the input' in a comparison nmcti"n ,kpend s on that function. For examp le, the input!; arc "ftype REAL in the comparison function CMP > R (compare REAL num bers for g", ater than). Variable, must be of the same data type as the inputs, When using operands w ith abwlulc addn:,scs, tbe operand w idths must accord with the data types . For ex amp le , you can use a ""oro operand fo r data type INT. You can find the bit assignments for the data fom )a!>; in Chapter 3.5.4. "Elementary Dal2 Types". A compari,on between REAL numbers is not true if one o r both REAL numhcr, are invalid . In a dd ition. :;tatus b ilS OS and O V arc set , You ca n find o ut h ow the comparison nmctions set the remaining status bi" in Chapter 15. "Status Bi,,"',

~ amples

Figure 9.1 provides an examplc for each of the data types, A comp arison functi on carries uu' " comparison according lU the characleristics spec ified .",-en when nn data types arc declared when using operands wilh ah solutc addresses.
In the cas, of incremental progrmnm.inl!'. you w ill find the comparison fundi"ru; in the Program E1cmcnts Cata log (with VIEW ~ OVER VIE>I,; [Crrl _ K] or L'ISERT ---; P ROGRA \l ELEME:"'TS) ulld<'f "Comparator'"

C om p aris on fu n ction in a run g (LA D) You can US<: tbe comparison function in a nong in place ofa contact You can C"fillcct contacts before and afler the comp ari",n fullction in series and in parallel. The comparison boxc, themselves can also be

Comp~r ls on

Aording

In

1"' 7

Memory b i' M 99 ,0 is reset if t"e n luc in memory word othe,""ise it 1> n<>t
CMP - - 1 M99 .0

~V

92 is equals to 120:

C MP --1

MW 9 2

Comparison a ccor din!/; to I) I<,-'T

'"

'N ' 'N '


.. ..

R)

MW92 -

-Globa l_DS-. CampYa l' -Global_DS-. Campllal2

.. fhe van"bl~ .. CompRc<ult in dam block G lobal_DB ,s Sct ,I vanablc '"CmnpVal l";,; less than CompValr ot h~rwi"e it is reset, "Global OS". CompResull C MP ~ D CMP< D "Global DS- , )f--I Compv;ol1 "Glab'!!_ DS-GiobaLDS", CompR" su lt IN1

..

'" ....

'" 'N' ..

M 99.0

Campva~ --L' ~N~'______f--'::C:~:S

'N'

IN2

If the V<ll1abl~ HActYal" greater than or equa l to the vanabk IIC"libm. #-Recah C omparison a ccording to Rt: A l.. i. ,et ' otherwise it is not
CM P IIActY"l _ jj Calibra
~R

#Recall

'N' 'N '

,)

CMP > R

IIActYal-

#Calib.-a

'N'

'"'

HRecali

FIgure 9.1 Comp.ri>oll Fuuctiuu Example.

'"

9.2 Description of the C<.>mparison


~onn"ctcd

Fun~tion,

in series or in parallcL In the case of comparison fun~tions connected in series, both comparisons must be successful for power to flow in the rung. In the case of comparators connected in parallel, only One ~ompare condition need be fulfill ed for powcr to flow in the parallel circuit. You can find further examples of the representat ion and atTangcmcnt of compari son func tions in th e program "Digital Functions" (function block FE 109) in the libmry LAD_Book that you can down load from Ihe publisher's Website (see page 8 ). Compa rison funct ion in a logic circuit (FBD) You can position the comparison fun~tion at any binary input of a program e lement. The resuit of the comparison can be subsequently combined with b inary functions. You can find further examples of the rep reselltatioll and arrangcment of comparison functions in the program 'D igital Functions (func _ tion block FB 109) in the library "FBD _ Book that you can do\vnload from the publi.hds Website (see page g).

with the data 'ype specified in the comparison function and checks to sec if the two values differ. The comparison is succes sful ("power flows through the comparator Output or the RLO is '.J .. ) when the two variables have different values.

If, in the case of a REAL comparison, one or both input variables are invalid, the comparison is not suc~essful. In addition. status bits OV and OS are SCI,
Comparison for grealer than The comparison for greater than' interprets the conten ts of the input variables in accor' dance with the data type specified in the comparison function and chc~ks to see if the value at input INI is greater than the value at TN2. If this is the case, the comparison is succe~sful (""power' flows through the comparator output or the RLO is 1),
If. in the case of a REAL comparison, one or both input variable s are invalid, the comparison is not successful. In addition. status bits OV and OS are set,

Comparison for greater than or equal to

9,2

Desnlptlon orthe COmpariso n


Functions

Compar ison for equal to The comparison for equal to interprets 'he cont~nlS of the input variables in accordance with the data type spe~itled in the comparison function and checks to S~e iftbe IwO v alues are equal. The compare condition is fulfil led ("power' flows through the comparator output or the RLO is '1) when the twO variables have Ihc Same value. If, in the Case of a REAL comparison, One or both input variables are invalid, the compari,on is not successfllL Status bits OV and OS are also sct. C om paris on for not equal to The ~omparison for not equal to" interprets the contcn" of the input variables in accordance

The comparison for great~'t" than or eqoal to" interprets the contents of the input variables in accordance with the data type specified in the comparison function and ~hceks to see if the value at input tNt is greater than or equ"lto the value at input IN2, If this is the case, the comparison is successful ("power' flows at the compar~wT outpot or the RLO is '1 "). If, in th~ case of a REAL comparison, one or both input variables are invalid, the comparison is not .uc~essfuL In addition, status bits OV and OS are set . Comparison for less than The "comparison for less tha n" intcrprets the contents of the input variables in accordance with the data type specified in the comparison fun~tion and ~hecks to sce if the value at input IN! is less than the value at input IN2. Ifthis is the case. the comparison is successful ('power' flows at the comparator output or the RLO is

,. IJ.

195

9 Comparison Functions If. in the case of a REAL comparison. one Or both input variables are invalid. the comparison is not successful. In addition . ' tatus bits OV and OS are set. comparison function and checks to see if the value at input IN1 is less than or equal to the value at input 11\' 2. !fthis is the case. the comparison is successful ("'power" flows at the comparator output or the RLO is "1").

Comparison for Ie.. than o r equ al to

The " comparison for less than or equal to" intcrpre1.~ the contenl> of the input variables in acco rdance with the data type spec ified in the

If. in the case ofa REAL comparison . one or both input variahles are invalid. the comparison is not successful Tn addition. StatuS bits OV and OS are sct.

10 Arithmetic Functions

10 Arithmetic F unctions

The ari thmetic functions combine two values in accordance with Ihc bas ic arithmetical opera ~ tions of addit ion, subtrJction, multiplication, ami division . You can usc the arithmetic runclions on variables of type INT. DINT. and REAL (Table 10. I),

output, OUT. The "he ader" in the box ident ifies the arithmetic function executed (AD!)_ I, for instance, stands for the addition o f TNT nnm~rs).

10.1 Processing an Arithmeti c Func-

tion
Represe n tatio n
A r i l h m ~t1< b o ~

(in <","npl~ : addition with tNT)


LAD repreSllntaUon

F8 0 representation:

'" '"' '"'


'N, 'N'

AO D_t ," 0 OU'

The values 10 be combined are at inputs TNI and IN2, and the result of the calculation is at output O UT. The inputs and the output have different data types. dcpending on the arith metic funClion. For example. in the case of the arithmetic function ADD _ R (addilion of REAL numbers). the inputs and the output a re of data type REAL. The variables applied must be of (~c same data type as the inputs or the ootput. If you use absolute addre ..es fo r the operands, the operand widths must be matched to the data types. for example, you can use a word operand for data type INT.

ff-

You can find a description of the individual bits in eac~ data fonnal in Chapter 3.5 .4. "Elemen tary Data Types".

ADD_I

I'u n cd on

="

OU, 'NO

f-

In addition to enable the input EN and the enable output ENO, a box for an arithmet ic function has two inputs, INI and IN2, and an

Th e aritiunetic function is executc<1 if "I " is present at (he enable input ("power" flows in input EN). Ifan error occurs durin g Ihc calculation. the enable output is set to " 0"; o therwise, it is set to "1". If execution ofthc function i~ not enabled (EN - "0"), the calcolation does not take place, and ENO is also " 0",

T. bl" 10 . t (ke,,'iew of A ritbmic Function.

ATithmctic function
Addition

With data type

Subtraction M ultiplication
D ivision with quotient os res ult D iv ision with remainder a. ,,:>ult

>NT ADD' SUB I MUC ,


DlVI

OINT ADO_PI SUO 01


MUl DI

REA'
ADD_R SUB R M UL_R
DIV R

'"

10 Arithmclic Functi{)ll5

IF EN "" '1 " or not wired THEN


OUT :. IN1

> Invalid REAL number in a REAL calcula"


ELSE
tion See Chapter 15. "'Status Bits". to Hnd out ll{)w the arithmetic functions Sel the various stalUs bil'.

:: '0"

Enmples Figure 10.1 shows an example for each data Iype , An arithmelic function exCculcS a calculation in accordance with the characterisl;c spec ified. even ifn{) data types have been declared when using {)perand, with absolute addresses.

If the MasterConlrol Relay(MCR) is activated,

{)ulpul OUT is set t{) zero when the arithmetk funeti{)n is processed (EN - 'T'). The MCR d""s not affect the ENO output.
The following errorS can OCCur during execu

tion of an arithmetic function:


I>

Range violation (overflow) in tNT ami


DINT calculations

I>

Underflow and {)verflow in a REAL calcu lation

In tbe case of incrc-menlal p[{)gramming. you win Hnd the arithmetic functions in the Pro" gram Element Catalog (with VIEW --> OVER' VIEWS [Orl - K ] or L.... SERT --> PROGRA~1 ELE" ~!E"TS) under "[mcger function" (INT and DINT calculations) and under "Floatin g-Point fcl. (REAL cakulalions) ,

Addition accnrdiog In 1r..'T

The value in memory woro Ivl\\' 100 is divide<! by 250, rhe integer result is stored in memory word M\\' 102.
DIV_ I

MW 100,~

Add.tIOn according to D1XT

..

'" '" '"


'N

'" 0
M

r-- MW 102

,
..

DIV_ I
-,"

MW1~ j IN2 :~1 250

0", '"0

r--

MW 102

The -.alues m vanables .. AnthVall and .. Anth\'al1 arc added and the r~sult stored in variable ,. ArithResult"". All ,'ariable, are stored in the data block.

..

ADD_DI

'"0
M

"Global_OS". MthVall "Gklba l OS". AI1thV"j2

- >N,

f-

"Glooal OS". AI1IhReSult

"GIobaL DS" , AI1\hVall "Global_OS" ,


At1IhV~1 2

ADD_ DI

'" >N,

0"' '"0

rIS

"Global OS", A,riIhResu ll

Add"'on accordinK 10 RI::AL

..

'"

The 'anable . Act\al and Factor are mulllphe<!. the prodnct " ,ariabte ii Display.

'"'

transferred to

MUL_ R

liActVa l liFactor

'" '" '"'

'"0
OC , #Oispay

MUL_R

liActVal #Factor

'" '" '"

OC, -

#Oispay

'"0

t"jgure 10. ' hample. of Arithmetic FUDcrio""

10.2 Calculating with Data TYJl<' II'.'T A r ithmetic fu nct ion In a r ung (LAD) Yo u ,",I'n ,",o nneCl ,",ontacts in series and in parallel before th,", EN inp ul and aCler Ihe ENO out put . The arithmetic box itself may be placed after a T_branch IlI1d in a branch that leads direcdy 10 lhe left power rail. This branch ewn alSO) ha"e eontlctS before Ihe EN input and il need not be the uppel1llost branch. Dire.:1 conneclion to the len po".er rail mean5 Ihul you can connect arithmetic boxes in paral_ lel. When you conned bo xes in purall el. you nd II coil 10 terminate the rung. If you ha'e not provided any error evaluation. assign a "dummy" op<..-rand to the eoi!. for example a temporary local dala bil. You can connect arithmelic boxes in series. If the ENO output of the pre.:edmg box lead5 to the EN inpul of the sub!lequent box. the subse quent box is processed o nly if the preceding box has been completed wilhout elTors . If you wan1to use the result from the preceding box as inpul value for the next box, variubles from Ihe lemporary local data area make ,",onvenienl inlennediate buffe!"!!. I f you ammge se,'ernl arithmellc boxes in onC Olng (parallel to the left power rail. then Further in 5eries). Ihe boxes in Ihe u~nnost branch arc pro<:esscd from left to rigbt. followed by Ihe boxes in Ihe secu",l branch from left to ri ghl. and su on. You can find funhe. examples of the rcpresenIlilion and arrangemenl of arilhmetic function. in the program "Digital Functions" (FB 110) in the library "LAD_Book" Ihal )'ou cM download from the publisher's Website (see page 8). Arithmetic funclion In a 1 0ile circuli ( fBD) If you want to proces s the arithmetic box in depend ence on specific ,",onditions. )'OU can arrange binary logic opera1ions before Ihe EN inpul. You can interconne<;1 the ENO outpUl with binary inputs of olher functions; for exam ple, you elin ammge arithmetic boxes in oe:ries, whereby the ENO O\Jtpu\ of Ihe precedmg box leads 10 the .'1 input of the following box . If you wanl 10 use Ihe calculation result from the preceding box as input value for a subsequenl box. v8ri"h le. from the ten'poraoy local data area make co nveni ent intcnn~-di ate buffers.
EN and
E~ O

need nOt be w ired.

You can find further examples oflhe represenI.IIlIon and arrangement of ~nthmelic fullCtionS in Ihe program "'Digital Funclions" (FB I to) in the library "H:JD_llook" Ihat you ""n download from the publisher's Website (see page 8).

10.2 C a l culating with Dilill Type lNT


L"'T additio n
The function ADD_I interprels lhe values at mpuls IN! and lN2 a!i numbers uf dala type INT. It adds the Iwo numbers a nd stores the sum III OUlput OUT.

ceo Ind CCI

After e.\co;ution of the calculation. status bits indicate whelher Ihe sum is negative. zero, or positivc. 5tot\lll bits O V and OS indicotc any range violations.

INT subtrwCllon

The: function SUB_I interprets Ihe values al


inputs 1..'1 I and ".... 2 as numbers of dala type L''''. h SublnlCIS the value .t 1N2 from the val"" alINI and Stores the diff~....::ncc in outp ut OUT.

ceo

After execution of the calculation. stat us bilS and e C I indicate whelher the ditTc", nce is negnt ive. 7.ero, or po,itive. SlUtus bits OY and OS indicate any range violoti(}ns.

1:-;1" multiplication

The funclion M UL_I interp~ts the values al inputs I},' I and TN2 95 numbe", of dala type INT. h multiplies the two nl1mbers and Slores the prodUCI in omput O UT.

ceo IUld eel


I,,"T division

After execution of the calculalion talus bits indicate whelher the product is negul iv e. zero. or po. itive. Stalus bits OV and OS indicate any INT mnge violtllion .

The function DlY_' interprets the values al mpu!:> TNI and 1N2 u numbcT"s of data type INT. It divides the \"Blues III input L 'll (d ivi_ dend) by Ille valuc ~l input IN2 (d ivisor) and supplies thc quotient at output OUT. It is the

'"

10 Arithmetic Fundio"s Oii," T dh1'lon "jth


'luo1i~nt

iDlcger result of the di vision . The qu()!i~nl is zero ifthc di,' id~'tld is equal to zero and the divi sor is not equal to zero or if the ab,ol ute ,alue "fthe dividend is Ie,s than the ab,olute value of the divi"or. The quotient is negative if the divisor is negativc . Aftcr execution of the calculation. status bits ceo and eC I indicate wb"l~er tnc quoti enl is negative. zero, of positive . Status bits 0'1 and as indi~al.C any range violations . Division by zen> proouces zero as quoti("1\t and 'CiS statu, hits ceo, eel, OV and OS 10 "] " .

u result

The fun~tion j)IV_ DI int~rpr~t' tbe va lue s at input' TNI and TN2 as nnml>ers of data type D INT. It di"ides the value at input L"I (divi d~ -nd) by the "alue at input IN2 (divisor) and ~tor~s tho quoti ~nt in output OUT Tt" the integer res ult of the division . n,e quo ti~nt is z~w i f the di vidend i, equal to zero and the d iyi,or is oot eqnal to zero or if tnc ab~olntc val ue of the di"idend is les, than the absolute value of the di \ i,or. Th ~ qll",i "" t is nq,;:aIiv~' i rlhe divi,or i, negali'e. Aft.r execution o f the calculation. starns bit, ceo and CCI indicate whether the quoti~D\ is nq:;aIi \'c. zero. or po;;iti ve . Stam, bits O V and as indicat. any range violations . Division by z ~rO produces zcrQ as quotient and setS status bil< ceo. ee l . 0'1 and as to " I ". DL,\"T
dl'" !~!on

10.3 Calculating with Data

T~'p",

DINT
011\, addition

The f"n~tion ADD _01 interprets the values at inputs IN I and lN2 as numb~'r:S of data t>pc DINT. It add, the 1"'0 num~rs and stores the swn in output OUT. After ex",", ut;on of the calculation. ,tatus bits CCO and cel indicate whether the ,um i, negat;ve, zero, or po,i live. Slalus hits O V and OS indicate Hny range violations. DINT subt r action Th e function SUH ])1 nHerp""" tn e value, at inputs INI and IN2 as numbers of data Iype O fKT. Tt ,ubtraclS th~ va lue at inp ut LN2 fTmn the value a\ inp ut TN ! and stores tne d ifference in output OUT After ex~U!ion of the calculation. , tatus hilS CCO and ee l indi cate whether the difference i, negativ~, ~cro> or positive. Status bits O V and as indicate any rnn!:" violations DINT multiplication fUIlction MUL_ Ol interpret> the ,"alue, al IN I and IN 2 as numbers of data typ~ DINT. It multipl in the two nnmber<; and ;;tores the produ~t in output OLT.
input~ Ib~

" 'lIh remaindu itS result

The fun~lion MOO_ Dl interprets the va l"", at inpnts TN I and DJ 2 as numixTS of data type D INT. It d ivides the valee a t input IN ] (d ivid~'lld) by tnc ,'aluc at input lN2 (divi",r) and sto,"", the remain der o f th" di " i,ion in output OUT. The r~mainder is what is le ft oWr from the dh 'is ion : it doe.' not eorresp<lod to the de<:imal p laces . If the d ividend is n egative, Ihe remainder is a lso negaI iv ~ .'uter execution of tbe eakulation, Slam, bits CCO and CC 1 indi~ale 1}. helher tbe remainder is negati"e . z ero, or positive . Starns bits OV aTld as indi cate any ran ge violations. Divisi on by zero produces zero as ,..,mainder and sets "aluS bits CCO. CC I, OV ami as to "I"'.

10.-1 C alculating \\ith Data Type REAL


REA L numbers are repre,ented interna lly as Goating_poi nt numbers "i'n tw o number ranges: One range with full accuracy ("norma lized-' floming-poinl n um~rs ) and one range with limited accurac y C'd~-n"rmali z ed" tloating _ point uumbe rs: al,o see Chapter 3 5.4, "Elementary Data Types"'). S7 -400 CPUs calculate in both ranges, S7-300 CPUs only in the fullaccuracy range. Ifan 57-300 CPU carries out a c alcu lmwn wbose resul! " in the limited -aeeu-

Aftcr execution of th e calcula,i un, "atl.lS bit< ceo and CCI indical~ whether th e produce is oq~ati"e, zero. or pusitiv ~. Stat u, bits OV and OS indicate any range yiolations

""

10_4 Calculating with Data Type REAL

riley range, zero is returned as result and a runge "iolation reported


REAL
~dd illon

REAL

mult lpll ~a t1on

The funetion ADD_R interpl"ClS the values"t inputs IN I and IK2 as numbers of dma type RI!AL It add<! the two numbers aDd stores the lIum in output OUT.

The funetiun MUL_R ;nterp("\~ the values at inputS I'll and JN2 as numbl.'TS of dala type RAL. It multiplies the twO numbto,... and sloreli 'he product in output O UT.

ceo and eel

After exccution of the calculation, status bits

Aner exccution o f the calculation, status bits eeo and CCI indicate whether !he sum is negative, "co, or positive. Status bits OV a"d as indicnle any range vio lations.
In Ihe cast ufan ilk sal calculati on (one oftne input vulues is an invalid REAL number or you "tempt to add +- and _), ADD_R returns an invalid val ue at output OUT and sets sunus bits eeo, eel, OV and as to "I". R EAL su blr _Cllon The function S UB R interprcts the value, at inpul s IN I and JN2 8S numbers of da1:1 type REAL, \t subtracts the n"mher at inpm JN2 from the n"mheT al input I", I and stores the difference in ompm OUT. After execution o f the c.leulatioD, 51atuS bils eC(l and eel indicate whether u.., difTerence is neaati,e. zero, or positi\'c, Statu, bits OV and as indicate any range vioimlions. In the C~ of an illegal calcul"ion (one of the input values is an invalid REAL number or yo" Kltempl t<l suhtract +_ from ...... ). SUB_R returns ~n invalid value at o"tput OUT and set> StatUS hi.,. ceo, eel, OV and a s 10 " 1",

Indieate ... Ilcther thc product is negative, ~ero. or positive. StatuS bits O V and OS indicate any range violations. 1n the casc of an illegal cal cu lat ion (one o f the input ,'aluc. is an invalid REAL tHunhcr oryou attempt to multiply ... and O), M UL R relurns an invalid ,'alue at output OU T a nd scI> "tatu.s bit$ eel, OV a nd OS to "I".

ceo.

REAL dl\l.oloo The function DIV_R int~rprc1.S the va illc, al inplltS IN] and 1N2 as numbeT:! of dala type REAL. It divides the number at input I~ I (dividend) by the number m input lN2 (dhisor) and .tores the quotient;n OUlput OUT. After execution of the c~lculatioD, status h i,", ceo and ee l indicate Whe~T the quotien l i.o nellati~'e, zero, o r posItive. Status bits ceo and ee I tndtclue any ran ge violations. In t he case of an illegal calculation (one of the input values is an im'alid REAL number or you attcmpt to divide ~ hy 00 or 0 by 0), DlV_R rctUnlS an invalid value at output OUT and ,ets SlatUS bits ceo, ec l. OV and OS 10 "I".

'"

11 Mathematical Functions

The following mathe matical function< BN: available in LAD and FBD:
~

Function The mathem:nical funcli,JO is cXCl.'uled if "I" is pTC!<Cnt &llhe enable input or if"po",-e.' nOW! In input E'1. Tf an error occurs in the calcula tion, the enable input IS sellO "0"; othe ....;sc it is SCI to "1". If CX~cullon of !he function is not enabled (E'1 the calculation dOC$ I\Ot take place and L'O is also ''0''.

Sine, co.inc, tangent rue sine, 111"0 cosine. arc tangent


E~ponential

c>

::. Squaring, 5quarc-roOl e"lntction


!>

function 10 base e. naNrallogarithm

"{n.

All mathe1TUlticai functio", procc, .. REAL


numhe~.

IF EN ,,- "1 - or not wired

THeN OUT ;.. Mfct (IN)


IF erro r occurred

ELSE

11.1 Procening Function


Rt pnsentulon

It

Mat ht'1II0tlc!l1

THEN ENO :" 0

ELSE

ENO :" 1"

ENO :- 0'

..-M Mf" .. _1><>1 1 _

The box for a mathematical fu~tion ba.. an input IN and an output OUT in addilion 10 Irn:

enable input EN aod the enable OUtput F'I10 The "rn:aJer" in the bo~ identifies the mathematical fu~tion exuted (for example. SI:" ~1.Ir>d.. for sine).
"a.h 1>0. (ia cumple: ,ioe)
!.AD rejlreHnltllion:

If the Master Conn-ul Rday (MCR) ;~ acti"e, output OUT is SCI 10 ~cro "'hen Tile mathemati , cal function is processed (J:::o. - "I"). The MCR docs oot aff..,t tile E"-"O. The follo,,;ng C11'OTS ~'\lIl occur in a matllemarieal function:
:> Range "iolation (underflow and o"ertl",,')
!>

'"'"0 '" =" ~ "" '" '"0 ~ ="


OU' OU'

:"0 vali d RFAL number as input value

Chpter 1S, "Stan.. Bils", e~pla;ns how the ma thematical fun~tions SCt Ihe SIRtu! bit s. Ex am ple. figure II . I soo'''!O three e~ amples o f matrn:IlllItieal functions. A mathematical function performs the calculalion ID accordance " ',th RE.-U even if no dau.typcs have been dlan:d ...hen uSlDg opc-rat>d. with ab.o]ute addR'cs. In the case nf increm"mal proaramming. you will lind the mathematical functions in the ProIP"'" Element' Catalog (with VIF.W ~ OVf.RVIE'" [Crr] - K ) or L'SJ:.IlT ~ PROGR"~ I En:'tESTS) und~r "Floating_I'olDt fet.".

The inpul ,-. Iue is al input IN and the resuh of 11\1; tnlIthernalleal funclioo is at output OUT. Input and OUtpul are ofdata type REAL. Operalld~ ", rel\.,,~ -d with albolu.c addresses must ... be double ... ord nrcrands. See ChnplCT 3.5.4. -'J:Jementary nata T)-p<:", fQr a d<;S(:ription of the bil S in REA L fOrTnal_

'"

11 . 1 Processinll" Mathemat ical Function

S in e

The value in memory doubleword MD 110 <:On,,,in. an anille in nldian m!l1lS\lTC. The sine of this angle ,5 senerated and ~tored in mcmvry doublewurd MD l(")oa.

I
S'ljuare
~,

MO 110

EN IN

'"

OUT ENO

MO '04

The .quare root of the value in variable ":-'hthValue l" is generutcd Hnd s10TC<l in the

variable 'MilhRoo!"".
SORT

'N
"Global_DB" . MathValue '

'NO
"G~al_OB .

MathRoot "G lobaL Oe". MathValuel

SORT

'N 'N

OUT ~ MathROOt

" GIobaII DB".

'N
The

OUT

' NO

Expo ne nl

~anable

"Re.llh conlalns the i>O"'oeT of e and

"E><~nt.

m
/tExponfInl
t"lgu~

m
' NO OCT
-

'N 'N

"'Reaull

"-'

'N 'N

OCT 'NO

#R ..~".. ~

11.1 Il umplci of Mathe-matiul Function.

l\h lhematlul fun e llo n In a runll ( LAD) YOII can connL"'1 contacts m series and in paral. le i before input EN and after output ENO. The mathematics box itsc lfmay be pl aced after a. T-branch o r in a branch that leads directly to t he left powcr rail. This branch can also have conlact s bef~ input EN and need not be the tlppenno SI branch. Thc direct connection to the left powcr rail a llows you to connect mathemati cs bo.~es in paralle l. Whell eonnectinll boxcs ,n parallel, YOII requ ire a coil to terminate the ranll. If you have not provided elTOr evaluation. as siSn a "'dummy" o perand to the coi l, for examp le a temporary local data bit. You can connect mathematics boxes;n series. If th e EN O OUl put of the prec eding box leads to the EN inpu l of lhe subsequent box. the subse " quent box is processed only if lhe preceding box hat been completed without C!Tors. I f you want to use the result from the precedillg box 95 the inpu t vulue Cor a subsequent box, variables from the telllpOrary lcx;pi data area make convenient intennediate buffers. If you alTllnge several mathematics boxes in one runs (pa rallel 1 the len power mil and then 0

!'uMher in series). the boxes in the uppcnno5t branch a~ the first to be proce!!sed from le ft to right. followed by Ihe boxC'< in the second branch from left to right, a nd so on. You can find funber examples of the representation and ammgemcnt o f mathematical functions in the program "Digital Functions" (FB 111) in the library "LAD_Book" thut you can download from the p ublisher's Website (s~ page 8).
) Ia th e milleal run et lon In a logIc circuit ( FBD)

If you want to have a mathematics box pro" eessed tn dependence o n specific conditions. you can program binary logic operations before the EN input. You can connect the ENO ou tput with binary inputs from o ther functions. For example. you can BrT"IInge the mathematic s boxes in serie!!. whe~by Ihe ENO output of the preceding box leads to Ihe EN input ortbe following box. If you want to use the calculation result of the preceding '00" as input "ai lle to u subsequent box. variables from Ihe temporary local dala a~a make good intermed iate buffers.
EN and ENO ne<:d not be wired.

11 Mathematical Functions

You can find further e~amples ofthe represen tation and arrangement of ma thematical func tions in the program ""Digiml Functions" (FB III) in the library "FBD_ Book" that you can download from the publisher's Website (see page 8).

a~ the inverse functions of the corresponding trigonometric functions. They assume a REAL number in a specific range at input IN and rerum an angle in !he radian measure (Tab le I Ll ).

11.2 Trigonometric Functions


The trigonometric functions

If the pcrmi%ib le value range is exceeded at input IN, the arc function returns an invalid REA L number and ENO - "0" so d sets stalus bit' CCO, CCI, O V and OS to "'I".

"N

COS

TAN

Sine, Cosine and Tangent

11.4 l\lisccllaneous MlIthcmatlcal Functions


The following mathematical functions n\'ailable

a"" also

assume an angle in radian measure as a REAL number at the input. Two lUlits are convemionally used for giving the size of an an gle: degrees from 0 0 to 360' and nodian measure from 0 to 21t (wh e"" II ~ +3. 141 593e+OO). Both can be con\'ened pro ponionally. For example, the radian measure for a 90 anglc is n/2, or + 1.570796e----00, With values greater than 2n (+6 .283185e+oo) . h or a multiple of 271 is subt11lcted unti l the input value for the trigonometric function i~ less than

SQR SQRT

EXP
LN

Compute the square of a number, Compute the square root of a number, Compute the exponent 10 b ase e and Find th~ naturalloganthm (logarithm to base e).

Computing the square The SQR function square. the value at input IN and stOres the result in output OUT. Example:
S~e

"

"Computing the sq uare root" .


~q ua re

Example (Figure 11. 2 or F igun: 11.3, Net" ork 4): Calculating the idle power p, ~ U' I sin{<p)

Computing; the

root

Table II.I Range of ate functions Functioo


P,rmi..ible
~ogo

Value Returned
- ,,12 to ""TtIl

"'"

I to + 1
I 10 +1

ACOS ATA.."

o to ~
,,1 to -~ ' 2 2

The SQRT function extracts the square root of the \' alue at input IN and stores the reslilt in out put OUT. If the \'alue at input IN is less than zero, SQRT sets status b its ceo, CCI, OV and OS to '1 " and returns an in\'alid REAL number. If Ihe value at input IN is ---0 (minus zero), ---0 is returned.

Full range

Example :

c - Ja' - b'

11.3 Arc Functions


The nrc functions (inverse trigonomelric func tions)

Figure II .2 or Figure 11.3, N~twork 5: First, the squares ofvariabks a and b are found and then added. Finally, the . quare root is e.~t,"cted from Ihe SUIlL Temporary local data are used as inter m~diate memory.
(l f you ha\'c d.-clared a or b as a local variable,

ASIN ACOS ATAN

Arc sine, Arc cosin~ and Arc tangent

you must precede it with # so that the Editor rec ognize, it a, a local \'ariable; if a orb is a g lobal variable . it must be p laced in quotation marks.)

,
,..-.:>ri< .. Calc u lation 01 ..actlva
MUL_R
~r

/NOItago "CUfT(lonl

'NO '"' 0"'I- Jtt..REAL 1 'N 'N'


MUL_R

itphl

'NO 'N '"0"' 'N

IIC REAL2

II'I_ REAL1 -

N e twork 5

'N 'NO r-#8_Powe, 'N' QU, IfLREAL2 'N' Calculati o n of h ypota nu ll


1- '0'

h~

II'I_REALI

"
"'-REALI
"'_REAL2

, , ,
Math~matical

FllU n> 11.2 Ex..mplu o f

Function. ( LAD)

Comput in g t he u pon., nt to bue

The EXP function compule> the c_~p<)JI"'lIial value!O base 2,7 18282e+OO) and the value al itlpll! IN (e ) and Slon:s the result in oUlpU! OUT.

The nanu-.llogarilhm is the inverse funcliQn of tbc ellponcnliai function: lfy - c'!hen x -In 'I. To find any logarithm, use the fonnufa log
b
<l ..

fJ-

!in.!! IOlilo
b

You Can calculate any expon=tial "RIlle the fannula

u~ing

whefC h or n is any base. Jf'lou make n " e, you can find a logarithm 10 any base using the nalllralloganttun:
IOlilb" _ In"

Finding the nalura l lo gatlthm

LN function finds Ihe natural logurithm 10 base c (- 2.718282c...oo) from the number m inpUt N and ston:os it in output OUT. Iflhe value al inpUlIN is leu than (Ir~ual to zero, LN sets status bill; ceo. eel. ov and as 10 'T' and returns an invalid R EAL number.

Th~

In the spec ial case for bllse 10, the ("nnuln ;, u follows: IS CI "

'" '

L~tO

- 0.43 42945 . In"

,os

II Mathematical Functions

...!:'ampk. of moth function.


Hetwort< 4 Calculation of r
cH~. pow~r

#Voltage -

MU L_R

<'

'"

OC;

I- ill_ REAL!

ftCurrenl

'"

<'0

"""
'0' <'
OC; -kt_REAL!

'" '"

""OCT
<'0

liLREAL2 MU L_ R

"
"CREAL ! itLREAL2

'" '"

O~

f-- #B_Powe,

'"0

N t twort< 5 Calculation of hYPolanu. .

,,-

<'

'" '0'

<'0

,
f-- #!_REA1.2

o c;
<'0

'" '"

#LREAL! -

ADD_R

<'

'"
'"

OC;

I- IIC REAL3
SQRT

/<LREAL2

<'0
lfCREAL3

<'

0 0; - " c
<'0

'"

Flgu,"" 11.3 fu.ampb of \fa,), om. tical Function. (FBD)

12

Conv~-rs;on Fun~tion,;

12 Conversion Functions

The conversion functions conV~"n the dala type of a variable , figu re 12 , I provides an overview of Ihe data type conversions de scribed ;n Ihis
~hal'lcr.

'CD
3 d ee.

'" '"
'"

~'NVI
INT

1.-/

NEGI

t 2.1 Prucessing

9.

Conversion

Function
Representation In addilion 10 the enable input EN and the enable output ENO. the box for a conversion function has an inpUl IN and a n OUlPU! OUT The header" in the box ident ifies the COnver sion flmction executed (for example. I_BCD stands for the convers ion of lNT to 8CD).
Con.-.nion bu

'" 0"

OINT

OOR lIRNO.. RND


REAL

RNO, TRUNC

0 '"
1

NEGR

Figure 12.1 Overview of the Convc-r.;on I'anctions You can find th e bit descriptions for the data forma'S in Chapler 3 .5 .4, "Elcmc"lllary Data Type"-

(in <",,"'plo: lNTto BCD)


LAD representation;

FBD represontaUon,

" , 'co
eN

I_BC D eN 0"' eNO

fFunction

'"

eN D OU,

The value to b e convened is at input IN and the resu lt of the ~onversion is at output O U T. The data type of th e input and th at of the ()utput depend on the eonv~"Thion fun~ tion . In the con versIOn functlUn OJ R (DINT 10 REAL). for in'l:mee, the input is of type DINT and the out put o f type REAL. The variables app lied mnSI be of the ",me data type as the input or the out put. Jf yon use operands with absolute addresses, the s izes of the operands must be matcbed to the data types; for example , you can use a word operand for data type INT.

The conversion function i, e xecuted if '1 " is present al the enable input (if ~urrent flows in input EN). If an CfTor oc~urs during ~on\'c,-,;ion> the enable output E NO is SCI 10 "0"' ; otherwise, it is set 10 "] ". If execution oflhe function is not enabled (EN - "0" ). the ~onvcrsion does nOI take place and ENO is also 0", IF EN "''' " 1" o r nOI w ired

THEN
OUT:" Confct (IN)
IF errO r occurred

ELSE

THE N
ENO ;= 0'
w,\b Con

ELSE

,"

END

"1"

ENO

,=0'

.. ""

"'<'"ion fun<ri""

'"'

12 Conve,..,ion Function,

Conwrtinll
INT
numb~ ...

The valu~ in memory double"ord MD 120 is interpreted as an [NT number and stored in memory doubleword MD 121 as a BCD nurnbel-.
I_BCD

MO 110 -

, . The \alue ,n vmable C"nl e"DlNT "lllterpreted as a DINT number and stored Convcrung UL\'T Dumber$ a rcal n umber in ,h~ van able "Con" ertREAL" ,
OI_ R "GlobaL OB" . ConvertD INT

'" '"

,"0

MO 122 MO 120

I_ BCD

0'"

..

'" '"

0'" '"0

r-

MD 111

~~

'"
'"

'"0
0'"
"Global_ OS" ConvertREAL "Global_OS", ConvertD INT

OI_R

Con-ertmg
RF;AL number.

. The absolute ~a lue "generated from 'anable I'DlSplay.

'" '" '" '"


'"

0'" ,"0

r-

"Global DB", Convert REAL

#Display

'" '"

'" '"0
0'"
#Display #Dlsplay

#Display

'"0

Figure 12.2 ExHIIlp1eS ofConn1"S'oo FUDclloo.

If the MaSICr Control Relay (MCR) i, ae,i,'c , output O UT is s~1 to zero when the convers ion function is processed (EN - " 1"). The MeR has TlO effN:t on output FNO Not all conversion functions "'\Xl" errors, An error oc~urs on ly if the permissible number range is exceeded (I_BCD. DIJ1CO) or an invalid REAL number if specified (F LOOR. C EIL, ROUND , TRUNC). If the input value for a BCD_lor BCD_ 01 con" yers;on contai ns a pseudo ' etrad, program cx~ cution is interrupted and error organization b lock OB 12 1 (programming errors) called, Chapter 15. "Status Bits". explains ho\\ the conversion funct ions s~t the ,tatus b its. Figure 12,2 shows on~ example for ~ach data type, A con"" .... ion function cOn'-ert, according 10 the <pcci tic characl rrislie tyen if nO ds,s types have been dttlar~ d wh~n using o!",rands with absolute addresses, [n thc C"-'" of incr~mental programming. you will find the conversion funct ions in the Program Elements Catalog (wilh VIEW......,. O VER-

VIEWS [Ctrl - K] or I"SERT """" P ROGRfuY! E LM.-"S) und er "CoD\'erter'",

Conn,,;on function ;n a ru n g (LAD) '(on can connect contacts in series and in parallel ocf""" thc EN input and a tter the b~O oUl_ put, The cooversion bo~ itsdfmay be placed after a T_branch or in a branch lhatlcads directly to the left \Xlwer rail. This braach can alS<l ~a,c con_ Iact, before input EN and it need not be th e uppermost branch. With the direct connection to the left po"er rail you can thus connect conversion boxes in parallel. \\'hen connecting boxes in parallel. yuu req,,;re a coiltQ terminate the rung. If you have not providM ~rror evaluatioo. assign a "dummy" operand to t~e coil, for instance a temporary local data b it. You can connect conversion boxes in ",ries. If the E~O output of the preceding box leads to the EN output of the subsequent box. the ,ubse quent bo~ is processed on ly if the pre ceding box has been completed w it hout errorS , If you

12.2 Conversion oflNT and DINT Nwnbcrs want to use the result from Ihe preding box as the inpul value for a subsequent box. variables from the temporary loeal data area make convenient intermediate buffers. If you arrange several conversion boxes in one rung (parallcl to the le ft power rai l and then further in series). the boxes in the llppenno, t bronch are proee"ed first from len to right. followed by the boxes in the sttOnd branch from left to right. ami so on. Vou can find funher examples of Ihe representation and arrangemCUt of conversion functions in Ihe program "Digilal Functions (FB Ill) in the library LAD_Book Ihal y(>u Can download from the publ isher's Website (see page 8). Co nversion funn ion in a togic dre ui! (FBD) If you wanl 10 process the conversion box in on specific condi tions, you can arrange binary logic operations before Ihe EN input. Vou can connect the ENO outPUI with binary inputs of other functions; for e xample . you Can arrange conversion boxes in scrics. w hereby the ENO output o f Ibe preceding box leads to the EN input of the subsequent box If you wa!\lto use the result from the preceding box as input value for a subsequent box. variables from the temJlO1""T)" local data area make good lemporary buffers.
d~'PC"dence

C ",n \"Hslun from I NT t o DINT The function I_ Dt interprets the value al input IN as a number of data Iype TNT and transfeIN it 10 the low-order word of output OUT. The signal state of b it I~ ( the s ign) oflhe input ;s trans ferred to b its 16 to 3 1 of the high_order word o f outpulOUT Th e conversi on from INT 10 DINT reports no e rrorS. Conven[on from [NT to BCO The function I_ BCD interprets Ihe value at input IN as a number of data type [NT and converts il 10 a 3-decade BCD number .. t output OUT. The Ihree r;g.h l-ju.,\ified decades represent the absolute va lue of the decimalnnmbec. The sign is in bits 12 10 IS. If all bils arc '0. the sigo is positive; if all b ilS are '"I"'. the sign is negative . If the INT number is too large to be converted into BCD (> 999), the I BCD function sets staIUS b ils OV and OS . The conversion docs not take place. Co nve roion from DINT to B C I) Tbe function DI_ BCD function interprets the ,al ue at input IN as a number of d ata type DINT and converts ;t 10 a 7-decade BCD number at output OUT. The sev en right_justified decades represent the absolute value of the decimal Du mber. The silP' is in bils 2R 10 31. Ir " 1I bits are '0, the s ign is positive; if aH bils are 1", the sill'l is negative.
If the DfNT number is too large to be convened to a BCD number (;> 9 999 999), status b its OV and as are Set. The conversion does not lake place.

EN .. nd ENO need not he wired.

You can find further c ~ amples of Ihe represenlalion and arrangement o f con version functions in tbe program Digital Funct ion~ (FB I l l ) in the !ihr.lr)! 'FRD_Book" that you can dOWTl load from the publisher's Website (see page 8).

12.2

Conversion of lNT and DINT Numbers

Tobt. I' 1 Con ___ ,..;on of TNT and DINT Numbers


D~I .

..

Type Cmwor_ '0<

Dat. Typ<: fur

sion

Porameter
~

Table 12 . t shows the conversion functions for [NT and DINT nwnber.. Variables o f tbe specified data type or ab solutc.addressed oJXrands of the relevant si~e must be applied to the inputs and outputs of the boxes (for ex..mple a word operand for data type lNT).

TNT to DIl,a
Th'T to BCD DrNT to BCD DlNfto REAL

, m
I BCD

~, ~,

OUT DINT
WORD DWORD REAL

DI_lICD DINT

D>R

DIN T

""

12 Conwn;ion Functions Con version from BCD to DL'IIT The function BCD_ DI inlCIprelS the value al input N a. a 7-decade BCD number and convens it to an NT number at output OUT. The ,e,-en right-justitied d""ades represent Ih" absolut" value of the d~cimal nun:bcr. The siS" is in bits 2~!O 31. If these bils are "0"-, the sign i, JXI,itivc; if they an: '1 ", the sign ;,; negative. Only bit 31 , ~tah-n into account in Ih" conyer ,ion. If th. BCD number ~ontain. a pseudo tetrad (numcrical valu(: 10!O 15 Or A to F i" hexadecimal), Ihe CPU s ignals a progtammi"g error ,md cal ls organization b lock OB 121 (synchm ni~ali on error), If th is block is ~ot available. the CPU go"s to STOP. The function

Conversion fronl ol:\"T to REAL The function DI_R inle",rel' the valu~ at inpul IN a. a number o t data type DINT and eon,'crt' it to a REAL number al output OUT. Si nce a number in DINT fonnat has a higher accuracy Ihan " number in REAL fOmlal, rounding mak~ take plac~ during Ihe con,crsian. The REAL numb~r is tben fOunded to (he next imcgcr (in accordan"c wilh thc ROU}.,'TI
Iiln~li on).

The Dl R funclion dm's not

r~porr

errors,

12.3 Com'ersion of BCD Num hers


Table 12.2 shows lhe fun ctions fM con,e't ing Hen numbers, Variable, of the specified type of absolutc-add,""ssed operand. oflhe rel~"ant ,ize must be applied w the inpul and o utput, of the (for example a word opcrn.nd for data tYl''' 11'< 1).

Hcn

I scts nO S\aluS biN

00"",

12,4 Conversion oCRE.A,L l"llmbers


Th...,.~

Tabl~

12 2 Co."",,ion o f BCD :-.Jumhers

IJMa 1'ype nmvo:r.,~

""
BCD_ l

[}at" 1'ype for

Paramete,

BCD 10 l"'T

"

OUT

WORD

lNT

are sev~ral functionS for eonv~rting a numb", in REAL fonnm to DINT tonrul1 ("onversion of a fraclional va lue to an integer) (Tab le 12, 3). They diff~r as regards ronnding, Variables of Ih~ sJ"'C ifi~d data type or absolutc addr~s>Ni doubleword operands rnllSt he applied 10 Ihc inputs and outpul S of the OOxes. Tabt. 12.3 , Com'GIS10DofIlEAl" om t C'T ' (DINT" ombe 0

]JCD t{, DtKT

HCrl_Tll O\VORTl Dm

Conversion from J)CD to I.:-IT The function BCD_l inlCrprctS th~ ~aluc al input TN a, a J - dccad~ Bcn number and conTh~ verts it to an [NT number at output three right-justified decades repr~".,nt Ihe absolule va lue oftbc dec imal num~r. Th~ sign i. in bils 12 to 15. If these bits are "0", th" sign IS JXlsilive; ilthey ar~ .')", the sign is n ~gat i 'e. Only b it 15 i, taken inlo account in the con\' ~r Slon.

nota Type ConvCT_


';011 ,,"'ilh Rounding
1'0 "." h igher

'"'
CHI. flOO R ROUND TRu'lC

Data Tyl''' for


P...-.-wxl~
~

0""
DINT
D~"

om.

RFAl
~

ial<ger To no,-l lo",.,. ,n '''ger To nD.. l inleg,'T


Without TOundinlj:

me REAe
intq:~r

O~"
DINT

If the BCD numh~r contains a p.eudo telrad (numerical value 10 10 15 or A !O f in hexadc~ imal) , the CPU ,ignal. a progra1llllllllg ~".(U' and calls organ ization block OB 121 (synchron i ~.a.tion error) . If thIS bl ock is not a\'ailabk, the CPU g""s to STOP The funCiion BCD_l sets no >talus
bil~,

R ounding to the

nc~1

higher

The function CElL inlervrels the value at input IN as a number in REAL fOmlal and comerr, it 10 a number in DINT format al output OUT. CEIL r~tums an inle ger that is greater Ihan Of equal to lhe number to be convened

12.4 Conversion of REAL Numbcni


T~bl~

12.4 Rounding Mooe, forthe Conversion ofll~.i\ I _ Number<

If the value al inp ut IN exceeds or falls short of the range penui"ihle for a number in DINT fonnat or ifil does not corre<pond to a number in REAL format, CEIL sets staNs bi t. OV and O S. Conversion do~. nottakc place.
Roundin~

If the "alu~ ar inpul IN exceeds of falls shon of range penni.sible for a oumber in DINT rommt or if il Jocs not corrc'pond to a numf>er in REAL fonnal. ROUND scts stalUs b ilS OV and OS. Conv~'TSion docs not take placc.
!h~

to the n ex t lower integer

:"0 0 Touod in!:

The function FLOOR imerpr<: ts the valuc at input IN as a number in REA L fonnat and con_ vert" it to a number in DtNT fOIDm! aT OUlpU! OUT. FLOOR returns an inleger lhat is less than or ~<iual (0 the number to be convened. I f the valu~ at input IN ~xc""ds or falls shon of Ihc rang~ permissible for a number in DINT format or ifi! d<>cs n<J! correspond 10 a number in REAL format. FLOOR SCI>; ,talu, bils OV and OS. Conver.;ion does not take pla~c.

The function Tl~UNC inlcrpn;ts the value al input IN as a number in REAL format and con"erts il tn a number in DINT format at nurpur OUT. TRUNC relUn15lhe inr~gercompon~nt<Jf th~ number to be convene<!; the m.ctional component is "truncatcd" ,
If the value at input TN cxcce<ls or falls shon of
th~

Ro unding t o t h e ntll t integer


The funcri"n ROUND interprels the value al inpul TN as a number in REAL format and .onv~rH it to a number in DINT fonnat at output O UT. ROUND Tcturns Ibe nexi inl~ger. If the result lies exactly betw~en an odd and an even number. Ihc cv~n number is given preferencc.

range p.:nnissible for a number in DINT format or if ir docs nOI COIrcspond tn a number in REAL format, TRUNC s~ls slatus b its OV and OS Conv~"",ion docs no! lake place .

Sum mary of con' erslo ns from R E AL


to D IN T Table 12.4 shows the differenr eff~cts of the func\ions for convening from REA L tn DINT. Th~ range - I to ! I has been chns~ll as examp le.

12 Convenion FunCiioru;

12.5 M iscella n('Ou5 Con v('n ion F un c tions


Other available conve",ion funct;O!I$ are onc's eompkme!l1 generatIon, negation. and absolutevalue lIeneration of a REAL number (Table 12.5). Variables of the spedfied data Iype or absolute. ftddrcss ed operand. of Ike rei evant ,ize IIlUSI be applied to the inputs and out pUIS of thc boxes (for example a doubleword operand for dna type DJNT).

Table 12.5 Misc<:lhme<>UO Con"mion rLlnCllOlll=,-_

One's complement D!l'o'T

O nc',

cump~ment

I"'T

The function !NV_[ negatcsilie value II inpul IN bit for bit and ....rites ilto output OloT [SV_ I replace, the 7.C"fIXS ,,~tb ~s and \~ce \"trY. The function [NV_ , does nO{ signal erron. O ne', eon' plement DINT
The function INV _01 negates the value II input IN bi t for bit and writes illo output OUT. INV_ 01 replaces the zeroeS with Oncs and vice versa. The funclion !NV_01 does nO! SIgnal errors. NEG_OJ i~ identical t<l multipli'lItion by - I. The function NEG_DI sets StaNS bIts CCO. CCI.OVandOS. Negatio n REAL

Negatio n INT
The fUnchOn NEG_I interpret. the \'alue 8t input IN as an TNT number. cbanges the SIgn throuih two's complemenl generation. and ...Titt'S the converted .-alue to OUlput OUT. NEG_' i5 identical to multiplication "'nk -I. The function NEG_ I iClS italUS bilS cco. CCI. OVandOS.

The function NEG_R interprets ,he va lue at input IN II.> a REAL number. multiplies this
nl,llIlber by -I. and "Tit~s 11 to outp ... t OUT. NEG_R ehange. the .ian of the manti$511 even <In an in"alid REAL number I'EG_R docs not ,ignal errors.

Neltllion DINT The function NEG_D1 inlerprccts tke value at inp ut IN ai a 0 Th.' T number, change, the .iin through two' ~ com plcme!l1 generation. and writes the eonvened value 10 output OUT.

The ABS function interprets the \'8.1ue al input D' ., a REAL number. generates the absolute n lue from thi, number. and writeS It to OUlpUt OUT. ABS sets the sign of the mamina to "0" e,'en on an invalid REAL number. ASS doe. not signal errors.

13 Shift Functions

13 Shift Functions

T he shift fu nctions shift Ihe contelll. of a vari able b il by bi t 10 Ihc left Or right. The b ils shifted olll arc either lost or are uscd 10 p a d thc oth~r side of the variable. Table 13.1 provides an o verview of the shift fu ncI;',n .

13 .1 Processing a Shift Fuuction


Repre.entation In addition 10 an enable inpul EN and an enable outpu t ENO. the box fo r a shift funct ion ha, an input IN, an input K, and an Olltput OUT. The hcader" in the box identifi es the shift function executed (for examr1c. SHL_ \V 'tands for shifting a won! v" ri"ble 10 the left).
Shin bQ ~ (i" oXH",]>le : .hi ll ", len
lAD , epresentation
"'~rd

p lIl have differen t data types depending on the shift fun~tion . For ex ample, input and OUlput atc of typ~ DWORD for th~ ,hill fun clion SHR_ DW (shift a doubl eword variable to the right) . Thc variable, applied most be of the .am e dala type as the inp ut Or output. If you use opelands with absolute addresses . the operand SiZC8 must ae~ord with the data lypeS; for instance, you can l'-V a w ord operand for dam type INT. lup ut N has data type WORD filr ev~ry shift fu nction . See Chapter 3.5 .4. "Elem~nmry Data Types" for a d escription o f the bits ill ea~h data fom,a!. FUBction The shift function is Gx<:cukd ,rI' i. present at [he enab le input or when power" flow, through input EN END is Ih en " I . If ex ecuI;on of Ihe function is 1I0t cnabled (EN - "0") . the shift does not lak~ place and ENO is a lso IF EN == -1 " or n ot wired THEN ELSE
OUT :- Sfet (IN, N)

by word)
SHL_W

,.
F BD representation ;

.'

, .. j -,'.

'" =," '"' = 'N


W N

,"0
OC,

0.

_W

oc, f-'"0

END:

.,.

END: = "0"

wi,!, Sf", ..

,\Un rune ';""

T he value to be shifted is at inpu t LN. the number of plac es 10 be sh ifted is at input N. and the ",,"ult is at oulPllt OU T. The input and the Ollt Table 13 1
Ov~rvicw

When Iho Ma<ter Control Relay (MCR) i. acti vated . output OUT is set 10 zero when thc shift function is proce ssed (EN - "I"). Tbe MCR does not affect OU!Pllt END. Chapter 15. StalUS BilS'"
e~plain.

uf Shift Function, Double"'Ofd


Variah l.
V~ri~bk

how the

shift functiOn> set the starns bits.


Ess ml'le<

Shift Fw>cti"IlS Sh ift left Shi ft right S hift w ith silfll \(otat. left I{otat. right

Word

'"' '"R
,~

SIll._ [JW
,,~

DW

hgnte 13.1 gives one example each for var ious shift functions .
In Ihe case of incl\.'IllCn lal p rogramming, yo" wii! find the shift funct ions in the Program Ele men ts Calalog (wilh Vlt-W --> DYFRVlFWS [etrl

SliR 01

. .

ROC OW
ROR OW

13 Shift Func tions

Shiftin!: ",ord ..ari_bl ..

The value in memory word MW \3 0 is ' hifted 4 position, t() the left and """,d in men'o,), word MVi D2.
SHL_ W

'" '" - '''' "


MWl30 -

'"0 0"' : - MW 132

MW 130

W11161J4

='" '"
-

SHL_ W

" ' "0


SHR_ OW "G lobal DB". ShiltOff-

0"'

MW132

Shifting doubleword
variabl~.

" Th~ value ill ymable " Sh,ftOu " lS , lufted fight by " SluftPos p'"",on. ancl stored in Shiftoft'

SH R_OW "Global DB". ShillOn: G IoI:>..I_OB".

ShifI?os

'" '"0 '" 00' r-"


SHR_ I

"Global DB" . Shil!Off-

"G lobaL ShiftOn

". '"
" "

00' ' "0

" (;lo.,.,I_ OB". . ShiftPo.;

Shifting with sIgn

The , an.ble I"ActVal" shifted. wnh SIgn. 2 posmons to {he nght ancl tmn,rorred (0 the vHriabl. liDi'pla," .

I>ActV,,1 -

W#16#2

'" '" "

'"0 00'

r-

JtDispl;>y

#Ac!VaI

W# I 6#2

='" '" "

SH R_I

00' ' "0

Jt Dlspiay

Figure D . l hampl.. of Sh ift Functions

" K ] or I:'SERT -) PROGRAM H EM[YTS) under


"S h i ftlROla {~".

Shifl function in

rung (LAD )

You ~aTl e mlTl e<:t contJ{\S in s~fies and in parnl leI be rore input EN and after output END.
T he shift box itself DllIy be plac~d a fter a Tbranch or in a bnm ch IhHI Icads dire<.'1ly to the le ft power rai l This branch can also rune conlaC," before input EN and it n~~d not be the UPl"'ffilost branch . The direct connection 10 the left pow~r rail allow. you to connect shift boxes in parallel. When co nne<;ting boxes in paralleL you requir~ a coil 10 tenn inatc the run g. If you have not proy id ed error cva lual;on. a.sign a dummy' ope<md 10 lhc coil. for example a teml"'rary local dala h it

You can connect shift boxes in sC"rics . If the ENO OUlpUl from tb. preceding box leads to the EN input of the s~bscqm;m box. Ib~ subsequent is ~l,,"ays proc~ssed. If you want It, use lhe r",uh from the pr~~cding box as input valu~ for a ,ub,equem box. variables from the tcmponry l ocal data area make a con,enienl imcrm~diat~ buffer. If you arrang e several boxes in one rung (parallel 10 Ihe kft pow" rail and then timber in series). the boxes in Ihe UppermoSl bran ch are rroce"ed r;"" 'rom left to right. followed by the box~s in the second branch rmm left to right, and '0 on. You c~n iind furth~r examples "flhe re presentation ,md arrangement of shift functions in the li brary Dib~tal Fun~tioIlS program (.FB ll!) in Ih~ library '"LAD_ R""k"' that you can down_ load from the publi'h~r'~ W~hsi {c (see page 8).

1).2 Shin
S h ift fORCll0 4 in a ru nlt ( FIlD)

If you want the shift boJ( processed in depen_ dence on specific condinons. you can arrange binary logic operations before the EN ;npln, You can connecl the ENO ourpU! with binary input. of olh ..... functions; for instance, you can arrange shift bo~es in series, "'hereby the EBO
output oflhl' """,OOing bo~ leads 10 the EI'- out_ put of the jub.~equent i>Ql(, If you "'am 10 use the re~uh from the preccrl'"lt box as input valuc 10 a subsequent box. variables from the Temporary local data area make coovenknt inlcnne<li

The shift number al input N :spccitle$ the num_ berofbit position. by which the contCn!S Ire to he shifted. It can be a constant or a valiable. If the shin number is 0, the function is not cxe, <:uled: ifi! is !>fcuter than 31. the outpUt variabl e contains zer(l following execution oflhe SHL_ ow fUOCl1on. Shift word ,"ui ab lc tn !h e r ight The shift function SI!R_W sb ifts the content . of the WORD variable a! input TN bit by bil to the right the number of posilioos lipcdfied by the .}nn number a, input N. The bil positions ~d up by the shift are padded with .tCroeS. The WORD variable at output otrr contain. the result. The .bift number at inpul N SJl'C<'ifies the n ~m ' ber o rb;1 positions by which tl>e contCllts are to be shifted. [I can be a COlmant or a vmiable. J( the ,hift number is 0, tbe function is nOI executed: ifil is gn:at.,.. than I !. !be OUlpUt variab le contains lero following execution of the SHR_ W !Unclion. Sh irt
dnubl~"'ord

ate buffen.
EN and ENO nc'Cd not be WiTN.

Yo u can find funhcr examples of the fepre!en_ talioll and RlTtiogernent of shift fu nction. in the

program "Digital function," (fB 11]) in the library ~FBD_Book" thaI ),OU can do ....TIlo,ad
frorn the publisher'. Wcb:Slle (sec page R).

13.2 Shift
S hift word VII r t. hle In the len The shi ft function SHL_W sh ift. (he conlents of the WORD variable at input IN b i! by buto the left Ihe numocrofpmitions specified by the shift number at input N. The bn posiliQllll ~ed up by Ihe shIft ace padded with :t~s, The WORD variable al outpUt OUT contains the result.
~hin number at inplll N specific. Ihe numberofbil pO.ilion. by which the COll!emS are to be shific:ci. 11 can be a Con~t.anl or a \ariable. [f the shin number IS O. the function is nQ! executed: ifi! is grealcr than I!, Ihe OUtput variable conta ins ~eT"Q foltowin!! execution of the SH L_ \'1 function.

... ri. bl~ to t he right

Tbe .hift function SHR DW sh ifts the COntentS oflhe DWORf) variahle &1 input IN bi! by bi lla the ria:h! the number of position. specified by II>e shift number at input '-'. The bit positiOn! freed up by the iihif't are filled wilh "eroes. Thc DWORD variable at output Otrr conla;ns the result. Tbe shift number al input N specifies ,he num ber ofbi! posi!ions by "hieb the contcnlll are!o be shifted. It can be. constan, or a vanable. If the .shift number is 0, 'he fUnclion is oot executed: ifit IS grcatertban 31, the output variable contain. zero following eXl'<:ution of the SHR_ OW funclion. Sh tf! word ,'. n able ..Ilh .ign The sh,ft function SHR_I sh ifts Ihe COntenl1 of the TNT vuiabk a! input IN bit by bil 10 'he ri ght the ~umbcr of positions spcci tled by the shift number at input N. Thc bil positIons freed up by the ,mil are filled ".. ilh tbe signal state of bit 31 (wbich is the sign of em N T number), thai is. with ''1)- if tbe number i. positi.e and

The

S h ift doub lf ..o rd n rl . ble 1 Ibe 0

1~f1

The .bift funClion SHI.._"W shifts the comenls of the O WORD variabk a! input IN bi! by bit to lhe left the number of positions spcd fied by the s hift number 81 input N. The bit positiQllll freed up by the shiA are padded with zeroes. 11le DWORO vanable at OUtpul Otrr contains the !"<."Suit.

13 Shift Functions

with "I " if the numb..r is negmiv~. T he I:"IT variable at output OUT contain< th~ result. The shift number at input N spec ifIes the numher of bit positions by which the contents are to he shifted. It ~"n be a ~(mstant or a variable. If the shift numb<:r is 0, the function is not executed: ifit is grual~T than 15, all bit pos itions in the output variable comain Ihe 'ign following e"ccution of the SHR_I fun~ tion. For a numb..r in data format tNT, ,hifting to the right is equivalent \0 division with an exponenti.,! nWIlhcr to ba.e 2. The exponent is the shift nLlmber. The result of snch a divi,inn ~"rre _ 8ponds to the integer rounded down.
Shift doublew'lrd ,'ariahle ,,;th s i::n

J 3.3 ROfale
Rotate doubleword varIable to t h e left

The ,hift function ROL DW shifts the content, of lh~ DWORD variable Bt inpu\ IN bit bybi t to
Ih~ left thc number of po, it ions sp<.'cificd in the shift number at in put N. The bi\ positions freed up by the shift are p added with (he bit position, that were shifted out. The D\VORD variahle at ompu l OUT ~ontains the result,

The 8hift function SHR_ DI shifts lhe ~ontcnls ofthc DTh'T variahle at input ll\ hit by bit to the ri ght the nu mber of positions srec1fi~d by tile shi ft numher at input N, The bil positions freed up hy the 'hift are padded with Ihe s ignal state of'bit 15 (whi~h is the sign o[ The DTh], num ber), that i,. with "0" if the number i, po" it ive and with " I" if the numbcr is negativ e . The D[NT variabk at oU lput O UT conta ins the re suit , The shift number at input N spccifi~ s th~ num ber of bit positions by wh ich tb~ contents are to be "hift~d. [t ~an be a conSlalll or a variable. If th~ "h,1I number is 0, the function i, not c..'\c cutcd; if it is greal~r than 3 j, all bil positions in !be outpnt var iable contain the si gn [ol1o"ing e )(ccution of the SIIR_ D[ funct ion. For a number in data format DINT, ,hi fting \0 the nght is equivalent to d ivis ion with an e .~po n .. -n\iaT number to ba , e 2, The expon ent is \.he sh m number. The resuit of snch B d ivision corresponds to Ihe integer rounded down

The ,hit[ nnmber at input N sp"cifie s the num her ofbil positions by which Ihe content, are to be shifted. It can b<; a constan! or a variable , If the shift number is 0, the funnion is not ~x e cuted: if il i.' 32, the Contents of the input variable me reta ined and the status bilS are ,el , If the shift number is .>3 , a Ihift of one position is executed: if it is 34, a sh Jft o f two positions is executed, autl so on (shining IS carried out modulo 32 ).
Rotat~

duublcword va rIable to tb. right

Thc sh ift fu nc tion ROR_ DW shills the coments o fthe DWORD variable at inl'nt TN bit byhi! to the right the num ber of positions srecified by the shift num\>er at input N. The b il po,ition, fre ed up by Ihe sh ift ar~ padded w ith the bi( positions thaI were shilled out , The OWORD variable at outrut OUT eonwins the resul\, The shift number at input N specifi~:l the num_ ber of bi t po,ilions by which Ihe con(~-ots are to) be shifted . h C,m b.. a constant or a variahlc . If th e sh ift number i, 0, the function is not ex e cuted: if iI' s 32, (he eonte1l1s of the input variable aN: N:lained and Ihe ,tatu, bit' are sd , If the shift numb~r is 33, a ,hift of one position is cxec1l1ed: if Ihe ,hift number is 34. a shift of two pO., ilions is exc~uted. and '0 on (shifting is ex ecuted modulo 32) .

'"

14 Word Logic

14 Word Logic

Word logic combine, th .. valu es of two vanabIes bit by bit accordmg to M'D. OR. or E"dusive OR. Th e log ic o!,<,ration may be applied to words or doubl='ord <;. The available word logk operations arc listed in Table 14, I.

TobIe H.l O,-eryi.w ufWor<! Logi c Opcnuion5


Word logk "P"ratl<>n
With.
w~

variable A-, D "


"'iAND_ W WO' W WXOR W

ooubJewurd v"';able
WAND_ DW WOR - OW
WXOR OW

0'
14.1 Processing Il \Vord Logic Operation
Repn~~entation

Exclusive OR
Fun ction

In additi"n to the enable input EN and (he enable output ENO, the box for a word log ic oJ)<Oralion has (wo inputs, IN! and IN2. and one outp"t. OUT. The "header" in Ihe bo" identifi es (he word logic operation .x~cUled (for .>:campIe. WAND_ W siands for word ANDing).
Word lo~i' bu (in cnmp le; 1\.'/0 operati"" "'oro b)' "otll)

The word lo gic operation is executed when I " is pre<~nt m the ermble input (when power flows thrm,gh the inpu( E"') _If e"eeu!ion of the operalion is not ~-nabled (EN - "0"). the open!tion does not take p lace and EKO is al,o "0"
IF EN ". "1- or not wired T HEN ELSE
ENO:" "0-

OUT:" lN1 Wlog lN2 ENO: - -' "

LAD representation;

WAND_W ENO EN

IN1

OUT

'"
FBD ,"presentation;
WAND W

"

If Ihe !>1aster Control Re lay (MCR) is active, output OUT is ,ello zero wben the word logic o!,<,nllioD is exec utcd (EN - " I"), The MCR docs not affect the ENO output _ Word I"Sic operation. gene['~tc K result bit hy bit. Bit 0 of input INI is comhined w ilh bit 0 of inputlN2. and the ",suit i. stored in bit 0 of output OUT. The same is done witb b it I. bit 2, and so on, up 10 b its 15 and 31, Table 14, 2 shows the result formation for a ,ing]e bit. Chapter 15, --Starns Bits", explains how the word logic operation' set the SlatuS bits ,
E~amples

INl

OUT
ENO

lN2

The values to be combined are at inputs IN1 and IN2. and 'he result of the operation is al outp"t OUT, The inputs and the " utput have different data types. dependin g on the operation : WORD for word ( 16.bir) o!,<,rations, and nWORD for doubleword (32-bit) op erations, The applied variables m us t be of the same data type as the inputs or rhe output, See Chapter 3 .5.4. "Elementary Data Types". for a description "f the bits in the vari ous data form ats.

Figure 14.1 show. one example for each word logic o!'<'ration. In the cage of incremental programming, you will lind the word logic operations in tbe Pro-

14 Word I.ogic

Tlo bl~ 1~ . :

R~" II Funn.1OI11n Word Logic Openl1 C u'"


ContC1lf>< ..finput TNt

C:..."enllO nf ,nrut TN2 R~ull w ith AND Knulr wi,h OR Reo"l, wi lh EM'\u.ivc OR

0 0 0 0 0

, , , ,
0

0 0

, , , , , , , ,

lMCIS before inpm EJ\ and il need not be the UJ'PCTl'"I'OSI brnneb .

The direct connection 10 the left power rail allowo you 10 connect won.! logic boxes in par alld. When conne<:fing bo"c~ in parallel, you require a coil to \erminate the ruog, If you have 1101 provided ~lTor .. valu&\i011, "S~'1>Il " dummy" operand 10 lhc coi l. for ex"", plc a temporary local data bit.
VOl' can e<mnect word l<>gic boxes in .cries. If the E:'-IO ompu! from the prcccdinil tx.>x l~ads t<> thc EN inpm of the subsequent boA, Ihc subo;c quem 00.' is alwaY" processed. If you w&nl '0 un the resuh of the prcceding hox as input value for a subsequent box. "art&bles from thc temporary l<x:a l data an:~ make con"enient mlc n m:diate bulf~Tll . If you ammge several ,,ord loak 1>u"~">1 ;n one rung (paraUd \0 the left power rniland tben further in series), the bo~e" in the uppennoS! branch are proceo.,ed firsl from left to riiht. fol

gram

meme~! ~

V! ~WS

Catalog (wilh V!EW...". O VER. LCn! KJ or INSERT ...". PitOl.iMM Ell! '

Mr:NTIl) uodC>" " Word Logic".

Word IoKie In a rung (LAn)

You can ammgc COOlatts in ...ric3ltDd m paral


leI before input EN and a1ler output 1"0. The "oro logic bo~ Llsclfma y he p lace<! a fter a Tbranch or in a branch lbal1cads dirlly 10 lhe len pow.". ",;t . This brancb can alS<.> bave con

The four high.".<kr b ttl of memory word MW 140 arc .1 10 .-0"; Ihe ""u l, ;.
stored in m<;OlOrv w o rd :>.1W 142 .
WIIND_ W ENO
O~ f -

OR

MWI40-

W.,6011FFF
IOIl:I~

'N 'N ' 'N'

MW 142

- 'N J.tw 140 _


W1f16/l"FFF

WANO_W
O~

Van ablcs wtoglc'\al l and \\ LoglcVal2 al'<' OR~d bu Cor bu lind tbe ",.ull oretl in W1.Oj;ICRCi lt'.
WOR_OW

..

..

..

..

'" 'NO I - MWU2 '"


WOR_OW

"Globio l OS". 'M..oglcVal j .

"

'"0
"GlObal DB".

"Gk>l><!ol OS" , lNloglcVall "Global OS". WLOQIeVal2

~~v~r

'N ' 'N'

0"' I - WLogkReall

"

'N' 'N' 'NO

0"' f-

"Glob31 OS"

WLOQIcRestl

t: ,du.h 'e-QR 'oglc

The ,,due i!C11<"I'lO,e<! by comb inin.l! n riabk.,. "lnpuI &nd I/\fask with Exclush e..()R is w ' "8riabl c ~ ~uff.,.

I c-~----1 EN WXOR_W t ENO+-- - - - - i


" /l'lropul tIM. .k
Hgu~

iIIflput ll'Masl< -

INt lN2

OUT I-- #Su".....

'N
IN1 IN2

OUT
ENO

I-- /ilSuIIer

14.1 Eumpko of Word toll'<' ep.ro.t;ons

14." Description oftbe Wurd Logic Operations spooding bit in both values tn be combi ned is
'" ]"

lowed by the boxes in the second branch from left to right, and so on. You can li nd timher ex~mplcs of thc r~pre,en tation and arrangement of word logic operations in tho program "Digital Function,' (HI Ill) in the library "LAD_ Book" that you. ~an download from the publi sher'. W~bsite (see page 8). Wo rd lo gic In H lo gl~ ci r cuit (FBD) If you. want to have the word logic box processed in dependence on 8pccir.~ condition s. you can arrange binary logic operat ions before the EN input , You can connect the ENO outp ut with binary inpms from other functions; for example, you can arrange word log ic box., in seri es, wbereby the ENO output of the preceding box lead, to the EN input of the .ubsequc-nt bo" , If you want to u,e the result fmm the preceding box as input value for a .ubsequent box. variables in the temporary local data area make convenient intcnnediatc buffen. EN and E:--JO need not be wire d. You ~an fLOd further cxamples of the repre,en tation and amtngement of logic operation. in the program " Digital Functions" (FB I I I ) in the library "FED_ Book" that you can download from the publisher'. Web site (see page 8) ,

..

Since Ihe b its that are "0 at inp~t IN2 also .et the eorre'ponding result bits to '0" regardl e~s o f what value thc,e bits have at input IN I , we also refer to these bits as being "masked", Masking i. th e primary use for the (digital) AND operation. OR ope r Rt lon OR combines the individual b its oflhe v.lue a l input [}.II with the corre'ponding b its of the ~alue at input!N2 according to OR. A bit >sult word OUT will be "0" only if the corre'pooding bit in both val ues 10 be combined is "0". Since the b its that are ., I '" at input IN2 also ,..,t the corresponding result bits to " t " regardless of what value thcse bits have at input INI, we also refer to these bilS as being "masked", Masking i. the primary use for the (digital) OR operation , EIcl u slw OR oper a tion Exdusi\ e OR combines the individual b its o f the \'aluc at input [)-ll with the correspondi ng bits of the value at inpm IN2 according to Exclusi, 'c OR. A b it iu result word OUT will be "1 '. only if tbe corresponding bit ;n only one of the tWO value, to be combined is .' I" . If a bit at input IN2 i. "I", Ihe corresponding bit in the result i~ th~ reverse of the bit at the sam e posilion in IN!. In the result, only those bits w;th opposing signal statCS in IN I and IN2 priOT to execution of the digital Exclusive OR operatio n will be " I ". Locating bits wiih opposing signal states or '"negating"' tbe . ignal states of indiv id ual bit. is the primary use for the (digital) Exclusive OR operauon.

14,2 D escription ofthe Word Lo gic Opera tio ns


AN I) operat io n AND combines the individual bits of the value at input TK I with tbe corresponding b its of the val ue at input IN2 according to AND , A bit in result word OUT will be " 1" only if the corre-

Program Flow Control

Program Flow Control

LAD nnd FIlD provide you with a variety of options forcomrolling the flow of the program. You ~an elt;t linear program eltecution within a block or you can Sl!ucture the progr"m with pn:!.vammable block calls. You can affect pr0gram eltecution;n dependence on "alues calculated at runt in",. or in dependence on process parameters, or in accordance with your plant st"tu.s.
TIle Itatuti htU pro,'ide information on the result of an arithmetic or mathematical function and on errors (such as a range violation during a ca leulat;on). You can incorporate the signal sUItes of the status bilS directly in your proaram usinjj: contacts .

I!I

You ~an usc Jump function. to branch unCOnditionallyor in dependence on the RLO.
A funher method of affecting progrllm execution is provided by the Muter Cont rOl RelA Y (MC R). Originally developed for relay comactor CQIIIrOIs, LAD and FBD offer" solW-lIre version of this program control method.

SlalUS Bits Status bits RLO, BR. CCO, CCI and overflow; setting and evaluating the stat us bin; using the binary result; ENIENO Jun,p Func thms Jump unconditionally; jump in dependence on the RLO Mint er Control Rday MCR-dependence; MCR range; MCR
=~

16

17

You can USe block functions to struCIlU"e your program. You can U$e function s and function block5 ag8in and ag5in hy defining block panmeter . Chapter 19. "J31ock Parameters". contains the examples shown in Chapter 5. "Memory Functions", and Chapter 8. "Counters". this lime programmed as functiun blOCks with block panllneters. These function blocks are then also called in the "Feed" example as local instancC$.

18

Bl ock Functions Block type . block caU. block end; stalUS local dalll; data block TC,ister, using data operand.; handling data blocks Block Pa rametcn Parameter declaration; formal parameters, actual parameters; passing parameten; 10 called blocks; Examples: ConveyOr belt, pans counter and supply

19

no

15 Status Bits

The status bits arC binary "flags" (condition code b itsj . The CPU usc, them for controlling the binary logic opcralioru; ami sets them during digital proc essing. You can check these statuS bits or act upon specific bilS. The slatus bit, ",e combined into a word, the SlaWS word. Ho,,ever. you csnnot scces. this slatus word wilh LAD or FBO.

LAD to the fm;t contact in a network , an d HlD to the first binary function input.

Ln

A bitlogi" st~p e nds w ith a binary value assignment (e.g. of a 'ingle coil or an a-'Signme nl) or w ith a conditional jump or a block change. These SCI IF C - "0". Hesu lt of the logic o p era tlon (RLOj

15.1 Description of the St utu s Bits


Table 15.1 shows the available status bits. The CPU uses the b inary flags for controlling the b inary functions ; the tl igital flags indicate mainly results o f arithmetic ami mathematical functions. Fi rst c heck T he fFe status bit 'lc~'TI> Ihe binary logic wi th;n a logic control system . A bit logic step always starts w ith /Fe - "0" anti a binary check instruction, Ihe first check. The firs! check sets /FC="I " T he fLr>! ehcek eorre,pondsin TK bie
1 ~. 1

The ItLO ,talu, bit is th" intcrmediate buffer in binary logic operations . In (he first check. m e CPU tran,fer. Ihc eheek r~sult to the RLO, ~ombi nes Ihe ch eck result w ith the Storctl RLO on cach subsequent eh~ck_ and stores the rcsult. in turn, in the RLO.
You can store the RLO with thc SAVE coi\Jbox in the binary ..."ul\ BR. Mcmory functions . timers and counters arc conlrolled using the HLO and cenain jump functions are execU1ctl. Thc RLO corresponds in LAD to the pow~r (lowing in the rung (RLO = "I"' is the sarnc as " rower tlowin[).

Slams il its

Bina ry Flags

!Fe
RLO
STA
OR BR

first Chock Re<uit of logic


0r><r~tion

Slatu,
Stat u, "it OR

StatttS bit STA ~orrespontls to th~ signal ,lale of Ihe che~ked binary operand . In the case of memory fttnctitms_the value ofSTA is Ihe , a me as the writlCIt ,a!ue or (if no wrile op"ration takes place, for cxarnpJ<: ;fthe R LO - "0" or th e MCR is acti , 'e), STA corresponds to the val ue of the addressed (and unmoditi etl) binary operand.

Binary ""uit

Dlgltol F1a ~. OS Ston."<i o,crflow


OV

Overflow

In rhe ca,e if cdg, evaluat ion' FP or fN, the \'al"e of the RLO prior to the edge evaluati on i. ,(orect in STA. All Nher binary f unctions ,et STA = " I",
The STA status bit has no effect on the processing of thc LAD or FRO fun n iortS.

ceo
CC I

Condition code (itala,) bil 0 Condition code ("atu,) bit t

nl

IS Stalm Ilits Status bit OR Status bit OR stores the re.ult of a fulfillw series circuit o r a fulfillw AND condition and indicates to a subsequemly pX:cs,ed paJ"llllel circuit or OR function that the ~sult bas already been determined. All other binary functions ,eselthe OR status bit. O verflow Status bit OV indicates a range violation or the use of invalid REAL numbers. The following functions affect the OV status bit: ArithmetIC functiollll. mathematical funclions, som e convers ion functions, REAL comparison functions.
1 ~.2

Setting the St al u S Bits

ThI: digilal functions affect statm bit. CCO. CCI. OV and as as shown in Table \5.2. You can check. tbese StalUS blls immediately following thc function box.
SIRI uS bits in INT gil d DINT calcu la tin n. The arithmclic function.; with data fnmllll$ INT and OiNT set all digital starns bits. A result of zero scts ceo and ce l to ''O~. ceo - ''0'' and CC I - "1" indicates _ positi~"C" result, CCO"1 ~ and eCI = "0" indicalts a negative result. A range violation ~I S OV and OS (please notc tbe Olher meanina o f CCO and Cel in Ihe casc of overflow). Division by zero i5 indicated by all digital status bits being set to "1 ". Stat us bits In REAL ukul. rio ns

You can c heck Ihe OV status b,t directly.


Srored on, rn ow

The OS slatus bit Siore s a sci OV Status bit: Whenever the CPU sets status bil OV, il also scts status bit OS . Howcver. while the nexl properly e~ecutw operation !"!:Sets OV. OS remains SCI. This provides you with the oppoTtunity of evaluatina a range vioillion or an operation wilh an invalid REAL number. even al a later point in your program. You can checlc status bit O S directly. A block change resets Ihe OS status bit. Sums blls CCO and CC I (condition code bits) Status bilS CCO Bnd CCI provide infom18tion Oil the resull ofa comparison function, an arithmetic o r mathematical runction. a word logic o peration, o r on Ihc bit shifted OUt by a shift function. You can check all combinations of CCO and CCI direclly (s~'C' below). Binary
r~SQ II

The arithmetic functions wilh dala formal REAL and the mathemalical functions sct aU diaital slatu" bits. A result of7.cro setS CCO and CCI to "0". ceo - "0" and CCI - ..... indicaleS a positi\"C" result. CCO - . \ "and ce I - "0" indi_ catcs a ncgative result. A range violalion '1:\5 OV and as (PlellK note the other meaning o f CCO and CCI in the case o f overflow). An in\"ahd REAL number is indicatw when HI! digIta l stams bits arc sel to "1 " . A REAL number is rercrred to as "dcnotma lized" ifit is repreuntcd with reduced accuracy. The exponem is {hen lero; the absolute value of I denormalizcd REAL number ;" Ie" than 1.17!! 494 x 10.18 . 57-300 CPU, rrcal denormalizcd REAL Illlmbcrs lIS though they were 7.cro (also sce Chapter 3.!!.4 , "Ek"1llcnlmy Data Type,"). Slal u$ bits for co n"enlon ruu ctio ns Of the con\'ersion functions, the two'S complements affect all diaital stams bits . In addilion, the following conversion functions set SlalUS bils OV and OS in the event of an error (range violation Or invalid REAL number):
I>

LA D and faD usc 5tatu.5 bit BR 10 implemelll the EN/ENO mechanism for bo~es. You can abo set, re~Ct or check SIatus bit BR yourself.

I_BCD and DI_BCD: Conversion of It-.'T and DINT 10 BC D CEIL, fLOOR, ROUND. TRUNC: Con"crsion o f REAL fO OU>.'T

:>

222

15.2 Sel1ing tile Statu S Bits

T"b.llo 13.2 S otting the Statu. B it>

I..'OT calcul.tion
The ",.uit is:

DIl'iT c alculotlon

ceo

CCI

< 32768
(ADD_ I. SUB I)
<

32 768(MUI.._I)

" ,
0

- 32 768 to

, "
0

, , , , ,
0

ov

The ,ult i.
<

CC"
0

147483648 (ADD OJ. SUB OJ) 21 4 7483648 (MUL 01) 2 147483 648 10

<

"

+110 + 32 767

>+32 767 (ADD I. SUIUJ ,. +32 767(MUL_TJ


)2 76H{OJV I)

" ,
" " 0 ,
0

( )65 536 Division by Uco

, " , , ,
0 0

" , , , , , , , , , ,

"

-1'0-2147483647 >+2 14 7483647 (ADD D J. SUB 01) >+214748 3647

(MUL DI)

2147483648(DIV_ DI)

H " 194 967 296


Di v i,ion by >:oro (DlV 01. MOD 01) Comp. ri.on

, , , , , , " , " " " , " , " , , " , , , , , , , , " , , , ,

ce. ov

0;

0 0

JU:AL c.lculation

The ,e<uit is:


+ DOnnalized '" denOrrn.'l1ized " zero nonnali,ed

ceo ce. ov

+ infinite (divi. ion by

~ero)

infinite (division by zero)


-to

imalid REAL number

" " " 0 " , , " , , 0 , 0 , , , , , ,


0

, " 0; , ,

The rult;s:
equal

CCO

ce. ov
0
0

0;

t<,

0 0

gre aler than


1 5 than
in,..lid REAL number

, , , , , ,
0
0
0

The resuh is:

Cotlnrslon

ceo cu OV

+ 1 to"'32 767 - 1 to 32767 ( )32768

"

"
0

0;

The .e>ult is:


0

:-a"c -D

CCO

ce. ov

0
0

-1 '0+2147483647 110_2147483647 ( )2 147483648 Word logic

0;

0
0

, " , " , ,
0
0

, ,

0 0

. Shirt function
The shifted out bit io: 0'. CC" CCI
0
0

"
0

, ,
0'

OV
0

0;

Th., result is:

Co> CC,
0

OV
0

t"
with shift nOln be. 0

" , "
.

"ro
not zero

223

15 SlatUll Birs Slatu. bit. for comparison functions Thc comparison funCliom set the CCO and CCI st alUS bil S. The flag' arc set independently of the e~ccutcd compari son function. Status bIts ror shm runctlon, In the case of the shift functions, the signal Slate of the wI bit to be $hifted OUt i. tmnsf=d to suuus bit CCI. ceo and OV are reset. Sta tu, bib for .. ord IUlle

15.3 Evaluating the Status Bits LAD : You can usc the nonnallyopen (NO) and the nonnallyc1osed (NC) contact 10 chk the dillital status bils "nd Ihe binary result . Figure IS.I shows the check with a normally-open contact. The check wilh a normally ..dosed conlacl relums the negalW cheek result. You can handle Ihe NO and NC contaCI5 for e\wuating the Slatus bits in exaclly the SAme W3y as lhe "1I0\"T11.11.1 contacts. You can find c~amples of evaluating the SlalU!; bi ts (FB II S in the Pro .. aram Flow Control"' program in Ihe "LAD Ilook" library Ihal you cnn download from the publisher's Website (sec palle 8).

If the I"Csult of the word IOllie operation is zero (all bits are "0"), CC 1 is reset: if at least one bit in Ihe result is " I" , CCI is sel. CCO and OV arc rcsc\.
LAD lalion >0

FRO
rcprewnlation

A cu=nt OOW$, o r the check

is fulfillw wben

-1~
> 0

-H~

--I f <0

=:-I~
<>0

--I f "0

--I f UO

--I f ov

--I f -

" --I f --I f Ftau"" 15.1

'R

I fI fI fI fI fI fI uo fI Ov fI " fI 'R f>0


0 <0

Resull gn:ateT th"" zCTO (CCO=O) & (CCI - I)]


Result greater Ihan or equal to zero [(CC()-())) Result less than ~CTO (Cc()-l) & (CC I-o) Result less than or equal to zero [(CCI-o)J

..0

<>0

Result not equ.llo zero [(CCtFO) & (CCI- !) ,,(CCO J) & (CC I=Q)]
Result cqUai lO zero [(CCD-O) & (CCI-o)] Result invalid (un~) ( CeO-I ) & (CC I" I)] Overfiow I lO V" ]] Slored overnow [OS- I] Binary result (SR- I]

Evaluating the Statu. ail<

'"

15.4 using the Binruy Result F OO ' Direct or ncgalC<.i check ing of the digital stan," bits and the binary result is pos> ib le. Thi s is shown in Figure 15.1 by di ..... checking tor ",t "igTlal "ale "1". The check fo r signal 'tat~ "0-returns the negated check r~sult. The checks for evaluation of the 'taN.' hits Can be treated el<aclly the same as the '"nonnal'" ch~cks for binmy operand,. You Can fmd e xam pl e, of uvaluating th~ status bits (FB 115 in th e pro. gram "Program Fl ow Control"') in lh ~ "FBD_ Book" libr"ry that you C~fl download fro m the publisbds W~b, it~ (see page 8). In the case of incremental programm ing, you will find these ~hccks in the Prul,'Tam El ement ' Catalog- (wilh YTFw ~ OVER\ll"T'WS [Ctrl - K ] or iKSERT -+ PRlX",RA .'1 ELEMENTS) un dC"T" "Stalus Bi t~" ,

program an a" ign box without binary opera11ds . P leas e note that tbe SAVE box docs not KTIninate a logic op~ra tion (starn, bitlFC is not se t to "0") . The next netwurk thus bugins with an "upcn" logic operation . The SAVE bux is not pennitled afte r a Tbranch, Controllinlilthe blollry
r~"ull

LAD and FB I) affect ev en the binruy resu!! in order to control the ENG output (i-' igurc 15.2). If cnabk output ENO is wi,..,d. il> signal ,tate i. the same as that of the BR. In certain cases (""OR corresponds \0 fWl~tiun"), \b~ LAD or fBD fun~tion executed sets the bina'Y result a, follo ws: HR,- "l" for MOW<. for the sbin fimctions and for the word logic operations
>

15.4 Using the Binary Res ult


15,4,1
Su !n~

S~ttjng

the Binary Result BR

OR := OV for the ari thmetic and mathemat;c,,1 fune_


I; on~

th. blnory ",,"It

LAD representa tion; FBD represenlaliorl

:>

BR :- OVor"I" for th e ~on version function s BR ;- BR of the called bIod,- in block ca ll s


th~ ~as~

------1 SAVE I

t>

of

SAVI': co il in a Fung (LAD) You store the RLO in the binary result using lhe SAVE c,,;1. Ifpown flow, into \h~ SAVE coil. BR is set, otherwise it is ",set. You program the SAVE ~"j] in the same way a~ II " ,ingle " cOlil without binary operands. l'lease note that the SAVE c'o;1 does not termi11atc th~ log ic op"ation (the !FC staw s b it is not set to "0"). Thi, means that the log ic operat;"" p receding 'h~ SAVE coil is also th~ preced ing logic operation for lh ~ next network. SAV E coil cmmot be programm<Od in conj unction with a T-bran~h. SAVE hox in a logk cir cuit (FOO) "\\'ith the SAVE bo" . you Save the RLG in the binary rcs"lt. If 'he RLO is "I" bdore the SAVE box, OR i, se t; othenvise, OR is resel. You progntm the SAVE hox \~c ""me way you
Th~

15.4.2 Main Rung, EXIE:"oIO Mecbani.m In programming hmg"ages LAIJ and FHD, many boxes h"ve an e nable input EN and an enable output ENO . If the enable input is "1", tk fun~tion in the box is proces;wd. Wben the box is process~J correctly. th e enable output also has signa l state " 1". If an errOr OCClIn< d"ring procc," ing ofa box (for example , overtlow dtlring execution of all arithm~tic fllItClion). .ENO is s~tto "'0" . IfEK h"" sigtl al ,tate "0", ENO j , a),,, 'ct to "0" , These chamcteri<tics of E'-I an d ENO can be uscd in o rder to connect se,eral boxes together in a cha in. wilh the enable output leading to th~ en able input oftb" n~x t box (Figu", 15.3). 11,i. means. for example. that the entire chain can be "disabled" (no hu~c, "rc processed if input I 1.0 in the ~ xample has signal ,tate "'0") or the ,..,s( of the chain is no longer p rocessed if one box signals an erro .

225

15 Stall>.' HilS

Is ENO switched?

v",

'"
'"

NO
Is EN switched 7

Is EN switched ?

NO NO

m
Is EN - - "t " ?

NO NO
BR :- ' 0' BR not a ff9CtBd

Is EN "1"?
BR corr ... SPOMS to tunc-

'R

,. "0 "

tion Fi\:" r.
1~ .2

spo nds to func lion

BR

corre

YeO BR ,. "t "

(jeneral Schellliltic for SOIling lk Binary Kosuh

The input EN anu thc outpllt ENO are not block parameter> bUI Si.<Hemcm sequences that th~ Program "Editor it<elf g.en erates plior to and fol" luwing an boxes (81~ o in the casc of [unction, and function b loch) . The Program Editor usc, lb e binary result 10 ,lore the ., ignal ,tate at.EN while the hlock i. being proc essed or to ch,'ck the error /lag from the box.
1~.4 .3 Ca~e

propnly processed; "0" jf an erro, has occurred during process ing of the block), All SYS tClI1 block> aho ~ignal group errors via HR .
b~~n

YOl' contro l the ENO output with the binary result BR. The ENO output has lbc same signal state that BR has when the block is ex iled.

ENO in th<' Block.

of \)s~rwrittc n

The Prow-am .Editor provides the call of your own blocb wi lb Ihe enablc inpm EN and th e enable outpu t E).IO. YOll ~an u, e the enable input EN to ~a11 the block conditionally. You can use the ENO output, for example, to 'ignal a group error (signal st<ltc " ' '', if the block ha s

1m,

For examp le, I3R coul d be set to " I"> at the ,tan of a block. It" an error lh~'!! o ccur> during pro " ce " ing of the b lock, for ~xampl~ if a result exceeds the tixed range "0 that further process ing nlU,t be f'1"Cvcnted, 8et the binary result to "0" with the SAVE ~oiLlbox and j ump to the end of the block w h ere th~ b lock w ill be =ited (in the event of an e rror, the condition mu,t supply sign"l . tme "{I"), Plea,c notc lhat the RET coi li box sets the BR to" I" i f you ~X il block via coiL-box ,

we

-it"' H - - '" ~ MD"1)}.;:::' 'N1 -, -.tOO-.,, . - 'NO ;~'.., -.I.i!~'

,.... ,.

OIV_ R

ROUND

Coo Utett

"

'"0 0"' f-#CREAl


#\ R EAL

'" "

'"0
OC;
iiLDINT

---'

EN IN

MOVE ::ioliO ~ ENO . H l OUT '.MO 3~;

c; ~~H~~--:;' "
E ND HIt"rc 15.3 Eumpl e fo, the Series Conn"" ,ion or.t;N and ENO

-" --

. '.:

'"

16 Jump Functions

16 Jump Functions

You can usc jump functions to interrupt the lin _ ear flow of the program and continue at another point in the block. This program branching can bc executed un~ondit ionally or d ependent on the RLO .

lowing comp ietion of the jump operat ion. The box w ith tbe jump label must be at Ihe stan of a network ("LABEL" in tho f>rogram Elements Catalog) , In the case o f incremental programming, you will find tbe jump functions in the Program Elements Catalog (with VIEW ---). OVERV!IlWS [Orl - K J or I,SEl'I,T --;. PRQGRA)'-! EU:.'fENTS) under "J ump.,".

16.1 Processing a Jump Function


Representation
LAD
rep r esenta l lo ~

JumpifRLO - " ]"

Dest ---{ J MP)------l Dastn ---(JMPN}-----j

Fu nction
A jump is e ither always executed (absolute or unconditional jump) or ;t is exeeutcd depending on the re sult ofthc logic operation (RLO) (condit ional jump). In the case of a jump dependent On the RLO , you Can de<:ide whether the jump is to be executed if the RLO is " I" or if the RLO is "0"

JumpifRLO - "O"

Entry, Jump

Jab~ 1

FBD representation

JumplfRLO - " ] "

Jump

iF RLO - "0"

Eotr}'. jump h,b.1

You can e .~ccute botb fo","'ard (in Ihe direction of program processing; in the direetion of ascen di ng neN.orK numbers) and baCKward jum ps. The j ump can take place only within a block. that is. the jump destination must be in tbe same block as the jump function . If you use the Master Contro l Re lay (MCR), the jump lahel must be in the sam e MCR zone or in the ,ame YlCR area as the j ump function , The jump destination muSl be designated unam biguously. that is , you muSt on ly assign a j um p labe l once in a b lock. The jump destination can be j umped to from several location s. The Program Editor ,tores the names of the jump labels in tbe non executable seetion of the rel evant blocks on the programming device's data medium. Only the wi dths of the jumps (jump displacement) are ,tored in th e CPU's work memory (in the compiled block). When program modifications arc made online to blocks in the CPU, these modifications m ust therefore always be updated on the program-

A jum p function consists o f the jump operation in the form ofa coil (LAD) or box ( FED) and a jump label d esignating the program location at whi c h proccssing is to continue aller Ihe jump. The jump labe l is above the j ump operation .

Jumps ~a!lllot be programmed in eonj UIl ct ion with aT_branch


A jum p lahel cons is" of up to 4 characters that csn include letters . digits, and the underscore . It begins w ith lclter, A jump labe l in a box d esignate, the network that is to be processed fol-

16 Jump l' unctions

ming d<:vicc's data medium in order to retain the original label lUlmes_ If thi. update is n ol made, or ifblocb are tnm,ferred from lhe CPU to the programming device, th~ nOll -e x~Ulable bll"". scc, ion< will b. oven,/riucn or del.:ted. On the di<play or the printout. tIle Ediwr then generates replacem<'-'TIt symbols for the jum p la bels (Moo l , MOO2 c'te.).

whose eoil is connect ed to the left power mil (LAD) or whose box ha< no preceding logi c operation (FBD) . This jump function is a!wa:,-s ex ecuted when encout\tcrcd in the program The CPU intcrrupts the linear fl ow of the pro gram and con (il1\Jes in lhe network d.signated by the j ump labe l.
E~ample (ri gure 16. 1 and Figure 16.2): In Ne(work 3, there is an unconditional jump (0 jump label M2 . After th is Tl ~twork has be~n proce"ed_ {h~ CPU cont inu"s program e:xecution at j u",p labe l M2 in Network 5. A jump from anothcrprogram location is required in order to ptoees. Nctwork 4 .

16.2 Unconditional Jump


The uncondit;onal jum p> which is the j ump that j, alwoys executed, is jump funclion IMP,

'~~Ork 1 Conditlorlal Jum p 1

If RLO

:i" '~---1 I t/compVall - (N1


I

.:,':

'

CMP~I

~-----{JMpH

Ml

tiompval2 -1.""~' '

___--1

: !'I.~.qrI( 2. Jump to "'II (5 not execut"d

1/-" ~lAcl f-I___________ (


. ~!,rk

iH

.,

.,

3 Uncondttlona( Jump

l~:+;;~~~~ ,_~-----------------------4(~~H ~~ .
CondlUon ltlJump 11 RLO _
"O~

"
Entry- 01 "'1 2

Flgu ," 16 .1 Jump FunctiOn< Exa mp le (LAD )

228

16 .3

JumpifRLO ~ "I"'

16.3 JumpifRLO="I"
The cond itional j u mp if RLO - "1" is jump func tion J.MP, whose coil is not directly con nected to the left power rail ( L AD) or whose box has a preceding logic operation (FED). The logic opemtion preceding this coil can be implememed in any way. If the RLO = "1" (if th e preceding logic operation is fulfilled). the CPU interrupts the lin ~ar flow of the program and continues in the network designated by the jump label If the preceding logic operation is nol flllJ11led. the CPU continues program e.~e cmion in the next nelV.ork. Example (F igllJ"e \6.1 and Figure 16 .2) : If the compare condition in N~1work I is fll lfiUed, projj:tam "x""ut ion eontinlles in Network 4. If the compare condition is not fulfilled, the next network. which is Network 2. i ~ processed.

16.4 Jump ifRLO

"0"

The ~ond itional jnmp if RLO - "0" is jump function JM:I'N, whose coi l is not directly connected to the left power rail (LAD) or whose box has a preceding logic operatioo1 (rBD). The logic operation preceding this coil can be implemen ted in any way. Iflhe RLO = " 0" (iF the preceding logi~ operation is not fulfilled), the CPU interrupts the linear tlow of the program and eontinll""s in the network designated by the j nmp label. Iflhe preeeding logic opera. tim1 is fulfilled. the CPU continu~s program ex .... cmion in the ne"'tn~twork . Example (Fig"re 16. 1 and Figure 16.2) : If the adder in Nero.ork 4 signals an error, the jump to 1','ctwork 6 Uump label MJ) is e X""\l\ed. If no error is signaled. Network 5 is the ne~t to be processed.

Network 1 Condittonat lump tf RLO.


CM P IICompVal2
*~ I

~ 1~

#CompVall

~=l'; ;'~ N IN2

__J___[jM~''e:J
JMP

N.twork 2 If jump to M3 Is not . " e cuted OutputO & InplllO

----l

Network 3 UncondItional Jump

Network 4 Conditional jump if RLO. "0"

#AnlhVa l1 _-l~'N;',--"O~';'}r-_~'~A~;~,"~R~'~'~____[i9M~'E: ' #ArithV,,12 IN2 ENO JM PN


Entry of M2

Ne twork 5

~ ~
.'t~ u r.

Input1 - 1

I {=='=:}______-{O="~"~'J'I
&

Network e E ntry of M3

Inpu12-1

I {=='=:}______-{O="~'''~OJI
&

16.2 Jump Function. Exam rl e (FBD)

17 Mo..ter Control Relay

17 Master Control Relay

In contact control systems, a Master Control Kelay activates or deactivate. a section o f the control system thaI can consist of one or more nmgs.
A deactivated rung
!>

w, EMERGENCY 0,..,.. or safety fUd/ity! Treat .HaSler Conrroi Relay switching in ",':aClly Ihe samC \i'ay as switch ing with a memory jimc1ion!
Wilh I,ICRA and MCRD. you de,ignate an area in your program in wh ich MCR dependency;" to take efteet. With in th is area. you use MCR< and MCR> to define one or more ZoneS in which th e MCR dependency can be enabled and disabled. You can also nest the MCR zone . The result of the logic operation (RLO) immcd;at~ly preeeding an MCR zone enables or disables MeR dependency wi th in that zone.

dccoergizes all non_rctentive contactors and retains the states ofrctemivc contactors .

!>

You C3lllot change the stale of the contac(01"$ again until (hc Master Control R~lay (MCR) is active.

Please nOle thai deenergiz;ng ",ilh the "soft",.are " Master Control Relay is no SIIbslilUtejar

17.1 MeR Dependency


"'lCR dependency am:ct8 coils an d boxes, If MCR dependency is enabled (corresponds to Master Control Relay disabled)
!>

LAD representatkm
A.Uv.te MeR .",a

a singk coiior assign box and 3 midline out-

Open ;I.(C(( .one


t>

put sN the b inary operand to signal state "0" (following the midline output. the RLO is thcn - "0", that is, power no longer nows) a Set and re set coil or box no longer affect the signal s13te of the binary operand ("freeze it") an SR 1lOd RS box no longer affect the signa l state of the binary operand ("freeze it") a ln1Il,r<:ropcration write s zero to the digital operand (every function OUlput ofa box of digital data type then writes zero to the operand Or to the variable)

Cluse MeR ,one

t>

FBD

r ep'a~entat i oo

t>

A.Unt. MCR o",a

-------l MCR< I
IMCR>I

Additional to the direct innuencing of an oper~ and the RLO is then "0' (power no longer flows) behind a midline output and aT-branch . Some LAD and FBD function. use tn.n,rcr statement. (inv isible to the user). Since a transfer statement write8 the value z ero if MeR d~pendency is swi tched on, the corresponding function Can no longer be guaranteed

Deoetlva l>ICR aITa

IMCRDI

17.2 MC R A rca

Yo" m'lSl exc/ude Ihl.< /hllm"'ng progra m ., ee_ litm.. / i-om MeN dependcn<y at/Wlldse the CPU ,1'111 go 10 STOP or "nde/in"J nmlim<! bd'''''io r <'un occur.
r>
I>

[eLrl - K l or b ' SERT --> PROGRAM ELEMENTS) under " Program C"ntrol" .

Dlock call s w ith block param eters Acce sscs to block panlII1eters that a ", pa_ ram"'"," types (e.g . BLOCK_ DB) Accesses to b lock parameter. that ar~ ~om pon~"Ilts or eiemetlt< or ~ompl ex data types or UDTs

17.2 :\'ICR Area

r>

You enable MCR dependency in a zone ir th~ R L O is '0" immediately priOT to op ening the zone (analogou, 10 disabling the MaSler Cootrol Rday ). If you open an MCR z one w ith R LO" I ( M a'tet Control Relay enabkd). p ro ccssing within this MCR 7.0n~ take, p lacc wilh_ out MCR dependc n~y . .\1CR dependency is cffccti v~' "nly within an MCR zon~, Tn ' hc case of in~r(:menta l programming. you will tind the MCR nm~tions in th e Program Elements Calalog (with VIEW --> OV.I'RVlI'WS

To b e able to "se the characteristic fearnres o f Ihe Master C omml Relay. ddin~ an MCR area \>"ith NlCRA (start) and MCRD (end of the M e R area), MeR depcn(kn~y i, aClive wiLh in an MCR area. but not yet ~nabled (F igure 17. I ).

TtIc MCRA coil/box and the MCRD coi!Jbox a lway!, ,'ann alone in separate n etworks .
If you call a block within an MCR aTca. M CR
dependency is deact ivated in the block callcd. An MCR area on ly Starts again with \hc MCI{A co il/box . Wocn a block is c xited, MeR dcpen<Jellcy is ,et as il was before the b lock was called. regardless of th ~ lI.ICR dependency w ith wrnch the callc d "I ,,~k W",", cx i ,~d.

Bh><:k 1

Block 2

Block 3

MCRA

MCRA

MeRA

Bloc+< call

BlocJ(cali

MCRD MCRD

B lock end

Block end

Bloc k en d

Fi\l:"'" 17.1 MCR Arc. in the Case "f Block Change

231

17 ;"1 _ Conlrol Relay

17.3 MeR Zone


LAD : You define an MeR ;wne with tbe MClt < coil (~tart) and tb~ MCR> coil (cnd of doe MCR zone). The MCR< coil r~u1Tl'~ a preceding Ingic opcl'mion: the MCR> coil is connected directly to the left power ra il. Both coi l. tcnninlite a rung. Within this zone, you control MCR dependency wilh thc RLO prior to the MCR< coil: If power flows inlo the e",1. _ \.tCR dependency is di~abled (,n onna" Prlx:es.in.j); if po" cr docs not flow inlo the coil, MCR d<.-pendcncy is cnahlcd.

You can open lID MCR !.OlIe within llllOth~ MeR zone. The nesting depth for MCR !.Oncs is 8; that is, you can o~n a lone up to eig:itl timc.~ hefon: you close a ZOne (Fililure 17.2).
You control the MCR dqx:ndency of a ne~ted MCR zone with tbe RLO on opening the lOIlC. However, if MCR del"'ndcncy ;'; en~bkd in a 'supraord inat e zone, you cannut disl,bJe MCR dependen~y in a ',ubordiMlc" MCR zone. The Master Control Relay of th e tiTSt MCR wne controls the MeR .lc-pendency in all nestll'd,

"'8D: Youdcfine an MCR zone with the MCR< box at the beginning and the :\fCR> boll .1 Ihe end oflhe :\1CR zone. The MCR < ho~ rcquin:s a precedi ng logic opcnu;on; the MCR> ho~ stands alone in a network. Within this zone . you control MCR dependency with tite !U.O preceding the MCR<box: If it i. '"1", MCR dependency i~ disabled (,"normal' proce~sln il); i f il is "0, MCR dependency is ~nabled.

A block call witbin mn MCR !.One ~s not emnie the nesting dc-pth II f an MCR zone. The program in the callII'd block is lIill \1\ the MCR zone that was open when the block was called (and is controlled form here). Ho"<c\er. you must reactivate MCR dependency in a called block by opening the MeR area.

In Fill"'" 17.3, memory bit~ M 10.0 and M 11.0 eontrol the MCR dependencie,. Wi t~ memory bit M 10.0, you can enable MCR depe ndCIl CY in both zones (wi lh "0') fCllard-

L&d

representation:
(MCR.4}-l

FBD rep' .... nt-'Ion '

I HI
t

! MCRA!
, 1.1

/MCRzon.

I,

(MCR<H

---l ---l
2J

MeR"'!

S"';Id:.ing QD ),liCk dopoJODCY III

MCR."""" I and Mt:R...-2

~1 .;

'I':' .rl< 2} 'ifMC"!hpn" ,.. , "t',


0

I ..

(MCR<H :

(MCR z_1J
t 1.1

MCR<!

S"'i<chi"" "fMC,,,
.wi t, ~e<I

~""Y


0 0

ill MeR ;:QIl' 2 ooly if MCR


deponden<:y in MCR rorlO T il

S-;,'l,il..

.~

"

{J..teR zone

otf

I I I

(MCR>H ,:
(MCR~H {MCRoJ-i

I MCR> I
! MCR~ !

I MCRO !

17.4 'ktlin& and R..~cuin& UO B;I>I

,.
MCRA

I I
[MeR zone '1

I MCRA I
[MCR zone I I

F-{.''"<f-{\ M 10.0 --i


[MeR zone 1]

MCR< I]

IMCR

ron&

[MCR

zone 2J

BlOCk call

MCR>

MCR>
MCRD

I MC RD I
" Iluft 17.3 MCR Zone> in Ihe Cau of llIod Change

le55 of iM C sig nal 5Iale of mem ory bit M 11 ,0, If the MeR d"pendency for zone I is d i, .. bled WLlh M 10.0 - " \", you can coutr"l the "feR dcpcudency of zone 2 With memory bit M 11.0 (T~bl c li.I).

to be COntrol led arc: in the pro~~ ss_i mage OUlput table or II procc,,-imaIlC output I" ble ha.~ b""n defin ed for the UO ar"a to be oontr"UeJ.

17,4 Setting aDd RC5C1 t1ng 110 Bin


Despite enabled MeR dependency, yuu can .et or rc~"'t the bilS of an JlO I'll'a with Ihc syslem
functions. A requirement for Ihis is Ihat Ihe hits

Th" syst"m function SFC 79 SE T is a vailable for :settin g and S FC 110 RSET for =<<!tting Ihe 10 bilS (Table 17.2). You call Ih"'" syslCTll f"mehons in an MCR :/;on". The system functions are on ly df<!{:ti"e if MeR d"pcm.lcncy is ennbkd; if MeR dependency i~ disabled. callina these SfCs has no effect ,

TMbk- 17.1 \1CR [kpcndcncy in Lbe ea.., of':'e.<tru MeR Zo...,. (Example)

MILO '" I ~

7.<>r>o 1

One :l

''0''

!>OO MCR dep..--n<knr;y Nn MCR dc-pendenC)' MeR dependoonc)' enabled

MCI!. depeodency """bled

17 MasterCODlml Relay

T~blc

17.2 ParamctCT< of the SFC. fo' Controlling the 1/0 Hi" P"""ncter
N

Decl ..... tion

D.ta Type
~ ,

m
N

VAC

INPUT OUTPtIT

on
POlJ'.'TER

"
<A

""'U,

OUTPUT

INT

RET_VAL

OUTPUT
OIJr ~UT

en
POINTER

A",isnment. Oc>cription Numh,,- of bit< to I>e .et FITor information Pointcr to the first bit 10 l>e set Number ofbi" to l>e reset Error information PUll"''- t~ the first bit to be res<:t You call rmd examples of the Master Comrol Relay and of the SystCID functions SFC 79 and SFC RD in function b lock FB 117 in the libraries "LAD_ Book" and "FBD_Book" in the rrogram "Program Flow Control" that you can download from the publisher's Website (see page 8).

Setting and res~t(in& I h~ VO bils aho simulta neously updales the process-image OUtpUl table. The 1/0 are affeet~d byte by byte , The bils not selected with the SFC, (in the tirsl and in th~ last byte) retain the signal stat~s as they arc currenlly availablc in the procc" image.

18 Block Fuocriom

18 Block Functions

In th .. chapter. you will learn ho" to call aDd terminlLtc code blocks and how to work with operands from data bloch. The n"xl chapter then deal~ wilh using blo;;k pl,ramctcrs.

conditions) is permissible. The block "'ml futM;~ lion RET always requi:, .. preceding logic ope..al1on. In additi"n to Ihc block change. Ihe cal l box alw contll;n. the tmnsfer of block parameters. Whtn fonclj<m blocks are called. it als<> opens the instance data block. Th .... CALL coilJbo~ is 00 _ than a change 10 anoth~"T block and is oruy muningrul (and pcnnis.sib1c:) in the case of functions and sy.l~m functIOns. After a block has been lenninatcd, and follow ing the call function, (he CP U contin"," pro_ !,Iram execut ion in the blO<.:k tbnt made Ihc cal l (tbe ...... block). If an orgnni:r.ation block is terminated, the CP U returns 10 the operat;ng $y$tem.

18.1 Block Functions ror C ode Blocks


Slod. functions for code blocks include instructions ror call;ng and terminal;ng blocks (F;gure 111.1). Code b!<xl;" (111: called with the cl,ll box. If functiollS or system functions havc no block parameters . they can also he called willl the CALL roil Or with tbe CALL box. In both cases. a pre<:edinj; logic op.,ration tnablina a conditilHllll call (call dependent on

nina

lAO rapr. .en !.lOtion


C.11InK on f8 or SFH whh d... bl""k a. 1"".1 instanU

D'.

Callin/( an Fe M STC with CALI. t><>. with CALL ooil

HI...... nd

["'ponde"t on RJ.n

".

OLn.me

IN' - '"

-- 'N OUlI -- IN'


,"0

'NO

OU"

,C.
'N
ENO

--{ RET}----i

IN'

mm

IN'

au"

.,

IN'
IN2

OU"
OtJT2

FBO "'prflSflntation:

C.III"iI an FB or SrB
with <13 ... bl""k ., 1"".1 'nS\8lnce

ComHi on Fe or SFC
wi!" CALL box

with .;m , "'-' r.; -",~""C"C .C---


CAlL OO~

,C.
EN
INt IN2

-1

'C.

o.."p<"do,,! on RLO

CALL

OUT1 OUT2
ENe

-IL-'c:'::.T-,

FIKure t8.1 Rlocl: Function, fnr Cod ... Block>

18 Block Functiom In Ihe case of incremental pn)~lullming, you will find the CALL coillbox and !be RET coill box in the Progrtlm Elemems Cata log (with
VtEW --J>
OVEll.VIEW~

[Clrl K 1 or L'SlRT--J>

rROGRAM I::LlMENTS) under "Pro~ Con-

Irol"; you insen block calls with caU box..,. mlO your progrnm when you select blocks from --FC/
J'H/SFClSr H bl<.><.:u", '"Multi ple In.tunces" or "Libraries".

.".

of Ihe call box that CO il or the called bl"d: (here: Fe 10). the enable inPUt [;N, thc enable OIltpul ENO, and any block puameters. Following proc~ingoftbc ~"Il function, the CPU OOnlinues progrHm cxec\U;on in the called block. The block is procc"ed to the end or IIm;1 a bloc k end function is cn~oumered. The CPU the n rerums to the calling: block (here: 013 I) arid
A block c"U

consi~t~

hlins the

ad~s.

cominucs proccssiull this

hloc~

alkr the call

If a code hlock i~ 1<\ be processed. it must be "call ed"_ Figure I R.2 g:ivcs an example for caUing functi on FC 10 in organiz"tion blo.>ck OB l.

C_Ili_1l b .... k. ~ .I. "'11_. 1... 11,," block O BI NetwoJ'k pIior to


~od< ca~

.. .
"

The infonnalion the CPU requires to find iiS way back 10 the euUing hloci< III stored in the block stack (lI sUlek), With every new blod:: enll. a new ,t"ck elemcnt is c""mcd that

N"twor1<: blOCk call wiII"I p"'ameteo"&


~ -- ~

, ,

1 1-- -1"" HH""


,, ~

Fe 10

'"0' -- - -1 '
r
04.0

\"1 _ 0

... --,
"ro<~,sin!l. oj"blod 1"''''mOl.... CO'ro!sIJQ",h ' ,,, p1W~,,;n/( of Ih. ~cl""ll'/zr;abl~., durinj{ "'"""'~

Ii

'N'
C..l1ln K bk><:k.
~ .~

,, ----C"lIfn~ rIt~ Mod M;'~ ""tfPI"",n <If 1M ",,=nt ""rlabl~1

a 'll" nt.",llon b lock O B I


ca~ pa~

i'Q

th. blocio: P''''''''<'''~'

Networl< pnor to bJod<

Netwo<t<.: DIOdo: caW with

--

Fe 10

;,
FiJ:;"'"" JIU Exampl. n( a Rlock Call

I g. 1 Block Functions lor Code Illocks

includes Ihe retum address, the contents of the data block register and the address o f the local data stack of the calling block. If the CPU gocs to thc Stop state as a result of an error, you can usc the programming devic e to sec from th~ contents of th e B stack wh ich blocks were processed up to the error_ You can transfe r data to and from thc called block for processing. These data a rC transferrcd via block parameters . With th e call box, YO ll can also call blocks without bloc k paramcters.

or ENO. You can only insert a call box in a paralld rung if it is connected directly to the le ft po"'e r rail.

rBD, You Can connect call bo~cs in ser ies by connce ting the ENO output of onc box with the EN input of the next. Th~ E N O OUtpUIS of~ev eral boxcs can be combined with AND or OR
.\-1eR dependency is de_activated when II block

18.1.2 Call Box You use the call box to call FBs, Fes . SfBs aDd SFCs_ (You cmmot call organization b locks since they nre event-driven and arc stancd by the operating system.) You can U the EN input to make Ihc bl o ck c all sc subjec t to conditions. If the EN inpul i, connected dirCCI to the left power ra il , the call i, absolutc: it is al ways ~x~cu:ed. If there is a log ic operation preceding EN, th~ block call i, only executed if the prececting logic operation is fulfilkd. The EI'O output has thc s ame s ignal state as the binary result BR on e xitin g the called bloc k. IF EN "''' "1- or not connected THEN Called block is processed IF called bloc k return s 8R = 1" THEN ENO :- "1 " ELSE ENO :" "0" ENO := "0ELSE Ca lled block is riot processed

is .allcd. The MeR is di,Hblcd in the called b lock regardless of whether the MeR was e~ ab led or disabled prior lu Ihe block call , Wl'en ex ilin g a block, MeR dependern;y asmme, the same setti ng that il had priur to the block call Depe"ditlg on thc block paramet~", you can modify Ihe ~ontcnts of thc dala block registers when the b lock change is made _ If the called block is a function block, the instance block is always opened in Ihis block v ia the DI rcgiSlcr_ If the calling block is a fu nction block, Ihe contents of the D l registcr (thc in stan ce data block) are retai ned aftcr thc block caU , The contents of the DB register depend, amung other things, on Ihe block paramct~rs that w ere passed, Calling function block. You call a fu"ction bl ock by .electing the rele"am func tion block from the Program Element.< Catalog under "FB Blocks". Pr~n;qu;sitc is that the function block to be called mnst a lready be in th~ u ser program_ You write the ins!an~c dala block belonging to the call above thc box. Both b locks (function blo<,k and in'tancc data block) can ha,c abso lU!e or symbolic addresses.

You lobc l th e parameters of the called block w ith thc absolut~ or symbolic operand current for the call. If a parameter is of data Iype HOOT... precede this parameter with

In the case of func tion blocks. you do nOI need to initial ize all block paramet~rs at th e call. The unin it; aH~ed block parameters rela;n thcir currenl value. However. b lock parameters saved..,; po int~rs shonld 21 least be initialized when called for the first time so that m e ,mingful values are ~ntered here (,ee Chapter 19.3 , "'Actual Paramclc," '").
You can also c all function blocks with multip le instance capabi lity" within other "'functio" blocks w ith multiple in'tance capability"' a, loc al instance , In doing so, the called function block uses the instance data block of the calling function block as the storc for its local data. Prior t(l the call, you declare the local instance in the static local data of the calling function

> a contact or a rung (LAD) or > a binary variable Or II binary logic operation
(FBD).
A Boo lean output parameter cannot be combined funhcr, LAD: You can arrange several call box~s in scri cs, connecting th cm with each other vIa E~

18 Block Functionl block (Ihe hlock you arC ~urrenl ly programming). The local illstancc " called by 5e1eClin g one o f the available local ill' tances under 'Multiple Instaocel' in the Program F.le-mctU5 Catalog; it is nut D~'CC;;:;aay to ,pecit)t an instance data block (~e also Chapl.r 18 1,6. "Slatic Local Data''). CalliDl:
functl"n~

You Cllll , I'Dr ~x amp lc. ~cle~t a sy.tem block frt)tn Ihe Program Elemenls Catalog with thc moo<' and drag it to the block c urrently being procnsed block. wbc-re it i~ then called. AI the same IUnc, this bl"ck (or. runIC precisely: ils inl4Tfac~ d.,scllption) is copied imo the block contninec. Hlock
~~JJ,

in

5equtn~~

(FRD)

You call a function by seleeling the relc"anl function under "Fe Blocks in the Program Elements Catalo~ The function C1lO have an ab.olute or a symbolic ndru-.,ss.

When you call functions . you available para11lete l"!l.

mu~l ini(ializ~

all

Calling runetions with a function value tab, exactly the.same fonn >IS e~l1ing fimel;on->' with no function value. OnLy the fml OUtput panuneter, corresponding to the functioo valll" _ has the name RET_VAL. Call in g 'Y"ltm blocks 'fhe CPU U]X'l1It;ng system cOIll~ills system Cunctions (S~C$) and system funclion bloch (SI'Bs) thai you can u.'<C. The numbe.- and type of.ystem blocks depend., on the CP U. You can call all system blocks with th., call boll:. VOII call a .~ySlc m function bl""k in the 5ame way 8., 01lC you have wrinen yourself: . et up the associated instance data block in the work memory with the !iIIm.. data type as th~ SFB. You call a system funct'on tht: "ame "'y "-~ a function you havc written you~elr. only in th~ C PU or>eraling ~Yl'tem. If you wont to call sy~t~m bloch during offliIll> progrnmming. th~ PTolP"m Editor oeeds a description of ~ call imerC....:e 1O ;1 can initiali~", thc ]lIllIll~t""'. You will fmd t/lli; interface ~pt;nn under S)slf~m Function Blocks on the librnry namc-d Sumdard Lihra,},. From here. the Ptogram Ed,[or copies the imerracc description 10 the omine hlO<'k colltA iner when you ~,,1L a ~y~tcm block. The interface description thm ~'Opied then appeDnl us "nor,nal" hlock objCCI. Syotem The Prognun Elc-men!..'! Cataloa provides the s)">tem blocks eW'T\:nt!y available ;n the u,,-,c pmgram WIder "SI'C BI""ks" or "Sfn Bloch".
hlock~ cx;~t

If you COnnect block boxe. in sequence in 1"00, and ha'e to "paSs 00" binary signals from one OOll: 10 tbe nell:l. you must observc the pr<>C<:SiI_ ing s..quenee of the binary logic operations by tbe program editor, The biruuy operand ~ and logic operation, arc initially processed prior to the bolt inputs, starting with the "last' block boll; the intermediate binlll)' results are saved in the temporary local dalu (not shown). FolluwLog this, the pmgnutl edttorproces.es tbe boxes thc-lIl.dves and th~ir binary ompulS , commcncina "ith the "fmil" box. Figure 18.3 c1ar:itie~ the processing S/: q\l~l1 cc. The OR box wilh the Ihn;c input~ i~ inittally procnsrd prior to the rialll block. then the OR boll: "'ith the twO inputs, followed by the left block call (~"Ontrol of Pumpl) and CID.1I1y the righl block eaU (l'um(2). Tile t=>porary local ~arilIble ",_PI Faull wauLd IherefOlre be scanned [lTSt (DIl Ihe OR box Wilh undelincd ~igna l state) and Ih ~n ~et (at lhe hinary o Ulp\\l of the first block caU). Thi~ could result in fo !sitlcation of thr result Olf the log;c operation. &:medy: ust' a globlLl '-ariable- (e .g. a bil memory Or a data bil; ",Ihi. ~HSr. a chang~ in status al the output of the til'!ll 1>10<:1<. would only be conSidered in the next Jlrngr~m ~yde "t the input of the ' econJ block) for pa,;,ing on the sisnal, or divide tht block calls bcl"een IwO nct" orl<,;.
18.1.3 CALL Colll8o'l:

,n

You cnn ~all functio!l~ ano.! system fu!letion~ using the CAI.L eoWhol<. II is a requiremet\l tbut 'he ,~ll~d bLock.s have no bLockpammrters , You eM use th., CALL enillbox if a block is 100 Jona or not clear .,nougb fOf you by ~;mJ'lLy llreaking down"' the hlocl into sections and calling the stttiOIU one aftcr Ihe other. One sinIIle CALL coiL or bolt is permit1cd per network.

23l'1

18.1 Block Funelions for Cotk Blocks

~ -.:, -:::J[==l~::-::.::. :j:;.;-~_""C=;- ~=.:~{:-~'-;'-..'.'.~ . =-~':~


I ....,.. - - '- '1""-" --

.. ......
-''-

.. _

H'

.. _

,- -..

........

..... " ' -

~. -

Fl~u""

18.3 Block Call. in S<><tunce (1'80)

eo;1 is connected dircetly to the call is always ex<'<:Uled (unconditional call). Ifth~re;s a logic operation precedmg Ihc CALL coil. Ihc call is only executed if Ihe preceding lo"ic Operation is ful filled. Ib ~t is, if power flows into the CALL coil . If the prc<:eding logic operation i~ nOI f,d filled. th~ call is nOt cxccll\cd and the next ne{ work is processed_ FBD : If there is a logic opention preceding {he CA LL box. the call is executed only wh<-n the preceding logic operalion is fulfilled. lhal is. when Rl.O" "1 '" is pr~scnt at the CALL box. If the precc>ding logic operation is nOI fulfilled, the call i~ not cxttuted and Ihe nexl nctv,o,k i. immediately processed. When a block change is made. status bit OS i. re$Ct: starns bilS cco. CC I and OV are nO! affected. MeR dependency is deactivated when a block i5 called. The MCR is disabled m the called block reprole.s of whelh~r Ih~ MCR "as enabled or disabled prior 10 the block calL When H block is exited. MCR dependency Hssumcs the .ame selling il had prior 10 Ihe block cnll. Calling a block with the CALL coilibox sa\-es thc data block regis!e", in the B stack: Ihe block end restores their contents "'hen Ibc called block is eXlted. The alobal datil block tlllTCtlt prior to th~ block call and Ihe instance data block are also open following th~ block call. If no datD block was open prior 10 tbe block call (fnr example. no instance UBlH block in OB 1).

LAD: Iftb~ CALL Ih~ I~ft pOwcr rail,

no datD block is open following the block call cuh~r. regan:ll~s of which data blocks may be o pen m the called block.

18. 1A Block End Function

You can tenninate processin" in a block prema. Nrely with Ibe block end function RET.
Condtlloul btod' ud LAO rOpnl!lenta\ion;

FeD

~Mntation:

--1

RET

Thc block ~nd fune{ion is rc-pre,;<;:nted as II coil or box requ iring II precedin" logic operation . Th~ RET eoiVbox muSI be olnn~ in II nelwork.

If the preceuing logic operation is fulfilled. thc block is eXiled. A return jump is made to Ihe
previously processed hlock in wbich Ihe block coli look place. If an organiul ion block is ler minated. th~ CP U .-c:lums to the system p rogram.
Iflb~ preccding logic operat ion is not fulfil1ed, the next nctwork in tho block is processed.

IF preceding logic operation .". "'" THEN ELSe


The block BR :"' " , "

t. ex ited

The next n elworl< i.

processed

BR

:c '0"

18

OI~k

fWKTions Thc temporary local data an:: stOred in lite L stack order of their dcclaTl'tion in accordance with their data type. Sy mbOlic add", lng of t~mporary local d ata You reference tempomry local data "sin~ their <ynlholie names. You lI.sign the se nameS in accordance w ith the rulc~ ror blocklocal ,.ym. bois.

The R ET roilJbox simultaneously StO~~ the RLO (whelher power flows or not) in binary 'Suit RR, ~~ardICl!s of whether or 001 the lo~i~ opcrt!iOl1 was fulfi lled. The binary ~ul! " decisive far coturol1ing the ENO outpUt at the call box (set! also <- bapter 15. StaIU. lilts'"). " 18.1.5 TCnlp"ra ry Local I)ala You usc the Icmpomry local data to buffer ~su1t~ Brisina during processin~ of a block. TemporlU)' lotal data are available only during bloc k proct'llsing; onCe a block ha!l been pT<). eessed. your buffered data a", lost, Temporary local data are opcnwd.< wbieh lic in the local darn stack (L .taek) in system memooy. The CPU's Qpcraring systcm malu:s the tempo. rary local data for a code block available when thaI code block is cal1e-d. When a block i. <':1, II<:d, Ih<,: value. in the L stack arc virtually ooineidenta1. In onkr to be able to ,"ake nnsi ble u<c aflhc local data, you ruu.t f1rst "rit~ them priQr 10 reading. When th e block is lenni n.,tcd. the L stuck is aS5igned to the next block ca ned, The number of temporary local data bytes a block require~ is in the block header. Reading the header lel1s the Op"rating sy.tem how many bytes have tQ be reserved in Ihe L nad: "ilen the bl()(:k is calk-d. You. too. can tell from the entry in the block header just how nuony local data bytt'llthe block requires (using the Editor, wilh the block open, by invoking F"u.E -+ PROp DtT1r~~ or in the 51MATlC Manager ","ith EDtT -+ OIlJECT PROPI:RTIl;S, in ea<;b ea.se on tab "Oencnd Part 2").
I)t~larln8 tfmpo~ary

All operatiO<)l; al10wcQ for bi! memo!), arc also allo","ed for tempol>Q)' local data. PJea;;c note, llowever, tbat a temporary local data bi t is I10t suitable for USe a. an edge memory bit because il does not retain its .ignal stDle oU!$'dc the rei e"ant block.
You Can address the tcmP'lRry local data for a block only within thai block (e)Cecrotion: the Icmpor,u), local data for the cRlling block can he accessed via block PlU1lmeters.)

5i,.e "f the L <tack


The 10tal size 01 the L ~tack is CPUspecific. The availahle number or tempornry local data byles in a priority cl as., that is. ;n the progrum ofan organi7lltion block, is also prcQelem'incd. On on 57300, the number of WI11pQRry local data bytes i. fc<~ for example Ihere II~ SIO bytes per priority ela~~ on Ihe CPU 314. On an 57-400. you can specify the number QflC1llpo. nuy local data byles you w,1I need wh~n you initialize the CPU. These bytes mUSI be: shared by the blocks called in Ihl: relevant organi~ti{ln block as well as by tbe block~ which Ihey ca ll. Please nOle that the Editor also uses temporary local data, for in'tan~c for pussillg hl<>ek param~ters. a fact which gocs unnot iced ou the pro~g inlerfa.e.
Decl.",,;""
STNtO
LB>~~

local dlltll

You deelarc the tcmporary local data in the dec


I..... tion """I;on of the c<>de bloc k:
I>

under"temp" in the case of inc",meDlDI pro gramming, or bet",""n VAR_TEMPand END_ VAR "'the ~a.sc of:wu",e""";eDled programming,

Data Type

A .....

I>

ARRAY [1..201
BYTE ARRAY [1..1fiJ l.IYTE

"

Figure 18.S shoWl' an e)Camp'c for th~ de<:lara. lion o f leffiP'lrary local data. The variable dif fen:nce li~s in the tL"IIlPOI1U)' local datu and is o f data type TNT; the variable b"ffe~ is of data lype REAL.

"1.0 20.0

"t .O

.'tgure 18." Example oflhe l),;..clar.... ;on otTcmporary Local Data


in an Orgonizotion Block

'"

18.1 Hlock Functions for Code Dlocks

Start in for ma!lon \\'hen an organization hlock is cal1e<!. the CPU operating system passes start information in !he tempomry local data . This start ,nformation comprises 20 byles for every organization block, and is nearly identical for all OB<. The start infonnation for the variou, organization blocks is describ<-d in detai l in Chapter, 20, "Main Program", 2 1. ""lmcnupt Handling"", 22, "'Stan -up Characteristics" and 23. "Error Handling". These 20 bytes of infomlation mUst always be avai lable in each priority class used. IfyOll program" routine for the evaluation of synchronization errors (programming and access errors). you mu,t set aside an add itional 20 bytes at least for Ihe start information of these error organization blocks, as these error ORs be long to the same priori ty cla". You dedare the start infonnation for an organization block when you program Ih at block. Tbe infoonation is mandatory. Sample declarations in English can be found on the Standard Libra/")' undCT Organization Blocks. If YOll do nOI necd the stan in formation, simply declare the f1r5120 byte, as something else. for example as an array (as shown in Figure 18.5). Absolut e add ressing of t~mpo rary loc a l data Nonnally, you reference temporary local data by their symbolic names. The use of absolute addresses is the exception. Once you are familiar with the way data are stored in lhe L stack. you can comput~ the addresses of the static loca l data yourself. You w ill a lso sec th~

addresses listed in the variable dedaration table of the compiled block . The operand identifier for temporary local data is L; a bit is addressed w ith L. a byte with LB, a word ",ith LW, and a doubleword with LV. Example: You want 10 rc_,erve 16 byte, oftemporary local data for absolute address ing, and you Want 10 reference the va lues in these bytes by both hyte and bit. To do this, creale an array at the beginning of the local data area so that addressing b~gins at O. In an organizat ion block, you wou ld place this alTay declaration immcdiately b~hind the dedaration for the stan infotmation. in ",hich CaSe addressing would begin at 20

A \'ariab1e in the temporary local dala can although this is an exception - he declared as data type ANY. You can use this fearnre to mooify the A;'o/Y pointer at runtime (sec Chapter 24.2.5 ..... Variable .. A.'1Y Pointer"). 18.1. 6 Slane Loeal Data Static local data are operands which a function b lock stores in its instance data block Static local data are a function block's " memory". They retain their values umi ll hosc values are changed by the program.just l i~c data operand, in global data blocks . The number of static local data bytes is limite<! by lhe data types of the variables and by lhe CPU-spedfk lcnb"h of a data block.

D",,\arat;on
IN

OUT 'N OUT


STAT
T~

Nao'e Man on Switd Length Total Sctpoint Difference Buffer

Data Type

Addrc"

Initial Value
FALSE

ROO'
H~'

'"

0.0 '.0

FALS E
0

<NT

INT DINT INT


REAL

'"
0.0 0.0

" .0 '.0

0 1.#0

Comment inpul parameter Output parameter UO paramoter Static local data Temporary loc,.l dala

~ll,l u. ~

111.5 Example of the Declaration of1.ocal Data in a Functioo Block

I ~ lJlock Functions

Ded arl ng static local data


You declare stalie local dala in Ihe declaration <ection ofthc runction b lock :
t> t>

In our lillie example, (h. data bloc k is named Totali::erData and Ihe data opcrand is named Tara!. The "ppli~"ble "ece .. instructions might be as follows:

under "<tat" in the grammmgor

~as"

of in~remcntal proMOVE "Total izer DaH!" . Total

belween VAR and END_ VAR in Ihe CaSe of source_oriented programming,

'N 'N

'NO

MWW

figure 18.5 in Chapler 18.1 .5 , "Temporary Local Data" shows an examrlc of a vari ahle declamtion in a function block. The block patameters are declared firsl, then the static local data, and finalJy Ihe temporary lo~al <uua. The .tatic local data are stored in the instance data block behind the block parameters in th~ order of Iheir decl arations and in accordance wilh their data lypes . Symbolic addressing of .tutic local dal a You rcference Slal;e local data wi lh symbolic I13mes. You assign th e.e name. in accordance with the rule. for b lock-local symbols. All the same oper,nioru; iliat ~an a ddress data operands;n glnhal data blocks can a lso address statk local data, Example: T he function hlock '''Totalizd" a<.Ids an input value to a value Siored in the static local data and then stores the t01a1 in th e static local data . A t the nexI call, the input va lue is again added to (his total, and '0 on (Figure I S.ti above).
70/"/ is a variab le in tb" data b lock "TotalizerData", the instance data block for the "Totalizer" function block (you can define Ihe names oCali b loc k< yourself in Ihe Symbol Table_ but you mu,t stick to the upplicable rule, when doing so). Th~ instance data block h", the data struclure o Cthc function b lock: in Ihe example. it contains tv,'O INT vm;"bles with the name, 1n and TOlal.

W C
MO~

"
o
Loc ul io"a nces

'NO

r- "Totalize,
Deta",
'o~

'"

ou,

When you call a function block, you nonnal ly specify the instance data b lock for thaI call. The function block then stores its b lock paramclc," and it' 'tat ic local da la in this imtance dala block Beginning STEP 7 V2 , you can generale "multiple inSlan~e"', that is, you can call a function b loc k as a local instance in another function block. The static loca l dala (and the hlock paramCte'"J of the function b loc k called arc thm a mb,et of th e caHing block's static local data. Prerequisile is that both lhe calling nmelion b l""k and lhe called function block huve b l",," wrsi<.Jt1 2, that i" tbat both have "mult iple in >tance ~ arabi lily". Thi, allows you (0 " nest" function block calls \IP to a depth of ~ i ght. Example (Figure 18.6 belnw): In the static local data of Ihe function block "Eva luation", you dccla", a variable Af",,,,ory that ~orrespon ds to th~ function b lock "Totalizer" and has its data sttuclUre . Now you can call the function block < "Totali/.er" via th~ variable Afemory, bUI w ilh_ out specifying a data b l""k bec ause th~ data for Afemory are stored "hinck_locally" in the <tal;c loca l data (,\Jl'mory is the loca l inSlance of the function bl"" k "Totalizer"). You a~ CCSg _ 4emory'. slatic local data in th e p rogram in runction block "Evaluation" the same way you would aeees~ slrueture components, which is by sp~ c ifying Ihe structure name (M~",ory) ,md the component name

Accessin g .ta tlc data nuhide the fu net inn block As a rule, the sta lic loe"l d"ta are processed only in the function b lock it>;elf. Because they are stored in a data hlock, however, you can access Ihe static lo cal data at any time with '"[)a/a Block Name".Operand Name j ust as you would a variable in a global data block.

(To/an.

'"

18.1 Block Fuucl ions for Code Blocks


FB "Total iHr" 08 "TotaolizerD8t&"

LAO representatIOn:

AOO
Olin onot.-

,
ENO

~ 0;;"
L.
F8 liTo\a1

'" '" '"

f - lITolal

In 'he Data "i~", Ih. (!~J~ M"'-'k , hm,'.' ul! ,n<llvi"",,/ mriabkJ '0 'hat 'h~ variable, <> a 1 local i''''alJc~ OPE'''''' ,.. II" Jh,i, ji,1I "am" . Simulmneousl)', you su 'he < """"".)i,,;: "" ab~ol"u addre5SS OS " EvaluaUonOat&"

"'"

ENOf-

" Ev elu8 ~on "

LAO ,epresentatk>n:

'!~&j I

#EM Add
''V''lue~'

"'Memory

I'

'N

'NO

I ~e l ete

#EM~O'"

'"
MOVE MOV E

I'

' N

'NO

0.Memory. Total ---, IN

OU ,

"ResullZ"

'" "

'NO
OU, f - .Memory,Total

1
, ,

' :"';'~

FBD fa <l$<Intation:

-"
#Oelete

"M,

'"0
"ValueZ" -

II'Memory

, ,
"

#EM Del

'" '" '"


'N

'"0 l-

"
MOVE MOVE

0-

'"

#M .. mory.Total -

,"0

f-- "Rasu lt2"

'"

0" f'"0 I--- #MemoryTotaI'

F12ur. 1H.6

E~amr l e

of Sialic Local D"a and Local In"8nc<s

18 Block Functi(ms

Th e instance: duta block '"EvaluationData" thus contain, the variables .\femory.]n a"d Mem ory. ro/al. which you can ulso ad<.lress as global variables. for example as "Evaluation_ Data .Memo"y. Total. You can fmd Ih is example of the use of a local in,llmee in function bloch FH 6, FB 7 and FB 8 ;n program "Program Flow Control" in the libraries ""LAD_Book'" an d "FBD_Book'". [hat you can download from the publi,her'. \\febsite (sec page S). The " Feed" example in Chapter 19.5.3. '"Feed Ex~mple" contain. additional usage of local instanc",. A b .olute addres>fng of .tat1e 10e.1I duta As a rule, the slatic local dala arc addressed symbolically. Absolute addre%ing is the excep_ tion. Within a function block, me instan~e data block il; opened via the Dl register. Operands in this data block. and this includes the ;;latic local data as well as me block parameters. therefore have DI as Op<.-rand identifier. A bit is addressed with DlX, a byte with DID, a word with DIW. and a doubleword wim DID. Once you know JUSt how data are stored in a dall. block, you can compute the absolute addre ..e< of the static local data yourself. You can also find me addre,s~s in me compiled block in the variable declaration table . But be very ~areful' These addresses w"l' addll?3ses 11.,,1 are relative 10 the slart of Ihe illSlance. They apply unly when you ~all me function block with a data block. If you call th~ function block as local instance. the local in'tance's local data "r<: located right in tbe middle of the call_ ing function block's instanc e data b lock. You can view the absolute addreoses, for example. in the compiled instance data block wh ich contains all local in.tances. Select VIEW --> DATA VIEW when you want to read up on the addresses of individual local data operands. Using our example as a basis, the "mable Total in the function block '"Totalizer" could be uddresscd with DIW 2 if function block "Total ;~er'" were called with a dala block (also lee the operands in me data block "'TotalizerData"'). and wim DlW 6 if function block "Totalize,'" wC1"C called as local in!tan~e in function block '"Evalu"tion'" (also sec the operands in data block '"Eva)uationData").

18.2 Block F unctions

fOI"

Data Blocks

You ;;tore your program data in the data bloch. In principle. you can also use the bit memory lm"'a for storing data; however, with the data block;;. you have s ignific antly mOre po'isibilities with regard to data volume. data stnlcmring and data types. This chapter shows you
I>
!> !>

how to wone with data operands. how to call data b locks and hew to create, delete and test data blocK. at nmtime

You Can use data blocks in two version." asglobal dala blocks that are not aSiiigncd to any code block. and as Instance dara blocks mat are assigned to a function hlock . The data in the global data bloc"" are "'free" dma thaI every code block can make usc of. You yourself determine thcir volume and structure directly through pro!,,'ramming the global data block . An in_lance data block contains only th~ data w ilh which the asso~imed function block works; this function b lock then also detemtines the stru~ and storage location of me data in "i ts~ instance data block.

The numb..r and length of data blocks are cpuspecific . The numlx'ling of the data block begins at I: the re is no dala block DB O. You ~an use ea~h data block either as a global data block or as an instance data block. You muiit rm;t Create (""!el up") the data bhx;kli you use in your progr~m, either by program_ ming, such as code blocks, or at rumime using the systcm function 5FC 22 CREAT_ DB.
R.~bt~rs

18.2.1 Two Data Bl,,<k

Ea~h 57-CPU has two dala block registers. The,e registers comain th e numbers of the Curr<:nt data hlocks; these are Ihe data blocks witb whose ope rands processing is currently taking place. Before accessing 8 data block operand, you muS! open the data block containing the operand. If you us~ fully-addressed :leeess to data operands (with specification of the data bluck. see below). you need not be concerned ,vi!h opening the data b locks or with th~ contents of the dala block rcgis tns . The Editor gen -

'"

18.2 BI<xk Function. for Data Bl<xks erntes me necessary mstru,;tions from your specifical;on5.
The Pr08T11tn Editor usu the firsl (lat" block register preferably for accessing global dala blocks and me second data block register for ac"",,,sinll inSlance dma blocks. For th;s rclLSon. these reglster~ arc given the names "Global (lata block relPster" (DB register for short) and "Instance Data Block Register" (Dl rt'gis[er for short). The lIanuling ofthe registers by the CPU ill absolutely identicaL J:;ach data block can be opened V;A one ofthc two regi,tcrs (or al.o via both simultaneously).
"0 come 10 the essential point

Symbolic access to the data op<.'f'lUlds in g lobal data block~ requires the minimum system knowledae, For absolutc acccss or for usina both data block registcn. you mUliI ob8crvc tJw.: nores beloW.

I[ is recommended that you addrelIII wua <>pl'fands symbolic.lI)' ,,henever possible. Sym bolic addressing
~

first: You can affcet only the DB regISter with LAD or FBD. If you open a data block wi th the OPN coilibox (sec be low), yo u always open it via the DH register, In LAD and FDD, the instance data block is always opened via the Dl regisler: this happens with Ihe call boll when the block is caUed.
\VIIen you load a data word. you must spe<:ify which ofl1le two possible open data blocks contain. thc dalll word. If the data block has been opened via the 1)8 register, the data word is called DI:lW; if the d.1l1 word is in Ihe data block opened via the \)1 register. il is called J)IW, The other datu operands are named accordinill y (Tab le 18, I).
Table 18.1

makes it easier to rt'ad and undeBtand the program (if meaningful lCTtllll are used as symbols), reduces "rite errOr~ made d.u:WII programmini (the ProifWll Editor compares tlte terms used in tbe Symbol T.. ble and in the program; "number-switchi ng errors" such as DaB 156 and DaB 165 that Can occur when using absolute addresses ctinnO! occur bere) and
does 001 require programming knowledge at the machine code level (which data block bas the CPU opened currently'!),

0.,. Operands

Symbolic addressing us"'" fully-addre.'lsed access (data block t0i<'ther with data operand). ~o that the data operand always hn a Imiq ue addrc . You detennine the symbolic addren of a data operand in lWO 5tep.!:

[)atab~

Olay

0.[. wurd

1)

A~signmem

oflhe dala block in lhe Symbol

Table Data blocks are Jobal data Ihat have un ique addres~ within a program. In the Symbol Table. you assign a symbol (e.g. MOlorl) to the ab$Olute addres~ oflhe datD hlock (e.g. \)ala Operands

111.2.2

Atcu~lng

DBSI).

You can use the followina methodS ing data opcrnnds;


~

rOT .ccess-

Symbolic address ing with full addressing. Absolute addre"';na witb full addreuing

"od
:>

Absolute addressing with partial addressing.

2) A.signment ofthc dala oper.:md.5 in the data block You define the names of the data OVC,",,,d8 (and thc data type) during programming of the dala block. The nalOe applies only in thc 'lSSOCiated b lock (il i, "block-local")_ You can also use the ume name in .. nother block for another "anable.

I ~ 1I 1oc~

Function.

Fully-addressed aeeHS to data operand . In the case Df fully_addre<sed acee". YDU specify the data b lock together with the data operand. This method Df addressing can be symbolic or HbwlulC '
"M7!"OR l- . ACIVAL IlB 51-DBW 20

18.2.3 Opening a Data Block


You use the OP1\' coi l (LAD) or OPN box (FB O) To open a data b lock v ia the DB register.
Open dato btock LAD representation'

f--{ OPN}------l

",

MOTORI is the symbDlic addre" tha t you have assigned to a data block in tbe Symbo l Table. ACrvAL i. th e data operand you defined when programming the data block. The symbolic name "MOTORI".ACTVAL is JUST a, unique a specificaTion Dfthe data opemnd as The specification DB SI.DBW 20. Fully-addressed data access is Dnly j"lOssible in .onjunction with the global dam block regisT er (DB register). In the case of fully-addressed data operands, the Program Editor firs! opens \he data block via the DB register and the n accesses the data op<:ratld You can use fully-addressed acec,s wilh all functions permissible fDr The data lype of the addressed d,tla operand. So with b lock parnmeIe,.,;, for example, you can also specify a fullyaddressed data op"rand "' <lemal parameler. Absolute addressing of data operands For absolute addressing of dala operand~ . you must know the addresses at which the Program Editor places the data operaods when setting up . You can fim] out the addresses by ourpulting them afterprog:ramming and compiling the daTa block. You will then see from The addres, colwoo The absolute address at which the relcyant ..ariable begin,. This procedure is , uitable for all data blocb. both those you u,e as global data blocks as wel l as those you use as inSTanc e data bl""ks (for local instance, see ChapTer 18.2.4. "'Special Points in Data Addressing"). in (his way. you can a lso see where The Program Ed itor stores the block paramelers and The slatic local data for function bloeb. oa(a openmds are addressed byte by b)1e like, for example, h it memory; the funCTion, used on {he data operands are abo Ihe same as those use,1 with b iT memory.

FBO representation:

The OPN coil!box is conneCTed d irectly 10 the left power rail ,md slands alone in a rung. The specified data b lock is always opened via the DB regi,teI. In LAD or FBo. it i.s ooT possible to open a data block via the 01 regisler with OPN eoilfbox. (The Dl register u.se, the call box to open The current irut:mce data block.) In th~ ca,,, of incf<-'IIlental programming, you will find Ihe Oi'N coil/box in the PWb'r.un Tilements Catalog under "DB Call". Th e open data block must be in the work memory at runtime. In the nCIWOn.:s following 'he OPN eoil!box. you ean use panial addre,sing to access only Those dala op"rand, that are locaTed in The open dam block. If you want 10 copy from one data block to another, you can, for example go into Ihe lemporary local data via an intennediaTe b uffer or (better) usc fully-addressed data operands. Pleas e note : A fully-a ddressed data operand o\erv"rttes the DB regiSTer with "its'" data block. EXmlple: The value of data word DEW 10 of data block DB 13 is to be Iramferred to data word DBW 16 of data block DB 14. With the MOVE box, you can only copy partiallyaddre,sed data operands within the currently open data hlock. For copying between d ata blocks. you require an intermediate butTer. such as a local data word (sec Figure 18.7). It is better to use full addre~'ing .
Wh~", you open a data b lock. it re mains "valid"' until another data block is opened. Under cerlain cir<;umslanecs, you IlliIy not be able 10 see this via the J>mgram Editor, for example if a block is changed with the call box (sec Chapler 1S.2.4. '"Special Points in OatH Addressing"').

'"

18_2 Block Flmclions for Data Blocb

~~~'i3'

,
DB 13 (OPN}----1 DB 13

I O'N I

Network: 6

Load from DB 13 and copy into a bllffer


MOVE

~ ." #CWORO .~:


~':,;,l

DBW lQ

' N 'N

0"' ~1iIt_WORD
DB 14 (OPN}---j

' NO

DBW 10

MOVE

'N 'N

OUT END

::;'[

....

Notwork 7 ; OpiIn data block DB 14

I
Networi< 8 MOVE , iIt_ WORD Network 9; -

I OPN I
~

DB 14

Copy 1T0m bllller Md transfor to DB 14

Copy with

'" '" '" '"

'NO OU'
MOVE

DSW 16 lit_WORD

MOVE

'N 'N

0"' '"0

O BW16

Iully--ad dr~uCd

data operands

'"0
DB 14.

0813 .
DBW12 DBW HI

M OV E

DB'3,; _ DBW12

'"
'N

OU , 'NO

_~B 14_ DBW 18

..
..

....

OU'

tn the c",~ of a block changc w ith the CALL eoilfbox, the co"t~'tl lS of the data block r~gist",-,; au retained . On returni ,,!! to the calii"g block. lhc b lock change rCston;s the old contents of the registers .

.tccess;ng block param~rer$


Access to the followin g b lock parJm~IC'" changc s the contents of the DB regi<ter: All block param~tc"" of complex data type in th e ea3\; o f functions, and ;n/ol1t parameters of complex dsta type in the case of function b locks .

18.2.4 Slleclal Chuoges in


lh~

Po int~

in Data Addre"ing
~egi st~r"

c"nteD" of {he DR

C" /linK "-funerio,, block >";th the call box


Bcfor<: the actual function block ca ll , thc call box ,lares the number of thc current ;n<ta nce data b lock in the DB register (by swapping the data b lock regi __ !ers) and op<..'t>s the in <tance dara block fur the called function block. In this way, the in<tancc data block associatcd with a c"l led function b lock j" alway< open. Amr the actusl block ~a ll, thc ~;,Jl bo x swaps data block registers again, so th at the current instance datu b lock is fl\'ailablc "gain in the c,,-lI; ng function b lock. ill thi s way, the ca ll box changes the contents of the DB register.

W ilh the following funccion<, the Program Editor g~n eral~' add;t;o nal instruction, which can alter tb~ e(ITllcn ts oflhe two DB rcgistcrs ;

Full ",]dress;ng of Ja/" operands


Each timc data operand, arc fully addressed. lhe Program Editor finn op<'"m 1he dats h loc k and then a c c ~ sses the dala operand. The DB rugistcr is ovcrW'riUen uach time . This slso applies to supp lying block parameters w ith ru lly_addre<sed dala operands .

18 Block Funclion;;

DI register in [omelia" blocks


In function blocks, the 01 register always conlains the number o f the current instance data bloc k. A ll accesS to block parameters or stalic local data is o"~" the 01 register. The address of Ihe local data g iven in the Oedru-ation Table of the f""c!ion block applies on ly when you open Ihc function block with an inSlan <: c d~ta block, in which ca;C the data operando begin at byte
~ero.

"0...,,,,-"

. A ~ ~Va h:.

t$l.Daw 10

where "Data" is tb~ symbolic address for data block DE I. If you would now ad d an a<l<litional da!>! word with the symbolic address klaxC",rell[ ;mm(Xl ;atcly in front of data word DBW 10, the rcsult upon the next opening (or storing) of!he code block will be as follows: In the case of "A bsoh<te add"". .' hlls priorily ": '
::Oata".MaxC-~r re nt

DEl. .DEW H

\Vhen you call a functio n block as lo(al inst"nc~, its data are "in the middle" of the calling data b lock's imtan~~ data bl""k. They contain tbe absolute addre<s of the \c,cal data when you output the in,tance data block in data view formal. Each individual variable is then displayed with name and address, including (he v,mable s of (he local instance called When yOll program a function block that you a l'o wam to have avai lable later a, local instance, you do not yet know the ~bsolut~ addrcss ofthc variable at the time of programming . In this case - JUSt as the Program Editor does for symbolic programming - (he content s of address rcgister AR2 lire added to the vari ab le addrc>s. However, this is poss ible only in the STL programming lang uage. Chan ging th e cont~nh of d a t R blo;:ks at a late r time In the PToper!ies window of the otiline objttt container Blocks in Ihe "B loch" rcgi,ler. you can "~ify whethcr the absolute address or the symboli c address of the data operand is to have priority for s"bsequcnt d;;;plays and savcs when thcr~ is a change in the contents of the data b lockS for code blocks (hal have already bcrtt stored. The default is "AbsolllIC address has priority" (the same a. in previous STEP 7 ver<ions). Th is defa"h mean, that when there is a change in the dec laration, the absolu!e add,,-,ss is rdained in the program whi le thc symbolic address changcs acco rd ingly. lfthe "Symbolic address has priority" default is chos(."n, the absolute add",,, changes whi lc the symbolic addrcs' i.' retained. Examp le: illsum ;ng that data word DEW 10 in d ata block DB 1 (ontains the symbolic address of ActVilh,e. In the program, you might adJ ress this data word wi th

In rhe ca.,e of ''Symhok' address has priority"','


"nat ... " . ActValu.

A, for a cces. !O data operand~ in global data b locks. tho same appli e, as for acce,,!O global operands (for instance inputs) for which a symboli c address has been entered in the Symbol Table . You will fi nd ,ktai1cd information on this subject in Chapter 1.5.5, "Address Priority". Note that this "rewiring"' does not take place automatically since th~ b locks whicb have already been compiled contain the executable MC7 code of the statemcn!s vei th lhe absolute addres . The change is only carried out in the !1:S~ociated blo~k (with a corresponding mes o sage) following op~ning and saving again. In order to carry out the modification in the complete block fold.r, 'ck~! EDlT ---> CHECK ELOCK CONS1STENCY with the Blocks objcc! sclteJ

18,) SY 5tem F unction s for Data


Blocks There are three system functions for handling data blocks . Their par~met~rs are dcs~ribed in Table 18.2.
I>

SFC 12 CREAT DB

Cre ate data block in work memory


l>

Sf C 85 CREA DB Create data block in ,,"urk memory SFC 82 CREA OBI. Create data b lock in load memory SFC 23 Dt::L DB Ddete data block SFC14 TEST_ DB Test data block

:>

18.3 System Table IS 2 SFC, for Handling Data B locks

Fun~tion"

for Data Block.

=i;;i;;

" "

;:,;;
~

rJ!
,',

, , ,
"

'6"~ ,
,
.
BH 16l'()4

,
,

"

.~ ~

, ,
, ,
I ~Y

"
,

, ..
,

,;,

,
;

,
"
~

~
H1 ~

b
,

block i5 initialized

"

, ,,

IS.J.I Crea tIng a I)at~ Bloc k In "\\'o r k J\femor J System functiom SFC 22 CREAT _ DB and SFC 85 CREA_DB create a data block in th e work memory. As the data h lock number. the system functi"n tak~s the lowest mc number in (he numbcr band given by the input paramctcrs LOW l.IMIT and UP LIMIT. The numbers <pecit1ed at these parameters a r C induded in the n umber b and. If both valu~s are the same, the <Ia\a b lock is ~reatcd with this number. The number of a data b lock already pres~"Ilt in the user program ~rumo l be assign~ d aga"l. n()\

even i ft he dala block is only pre,en( in the lOad memory. The output parameter DR NUMBER supplies (he n umber of the data block acrualJy ~rc "ted . W ith the input par"mctcr COUNT, you specify th e length of the dala block (0 be created. T h e length ~orrcspond. to the number of data byt~s and mLlst he an even number. Creati ng th e data block is not the same as call ing it. The current data h lock is still valid. A dat" block ~reated with this syst~"Ill funcliOTl contains random data . For meaningfu l usc, data

18 Block Functions n,e data al'~a a<> igned as default 10 the cr~a\cd data block is spec itie<:l ot input p arameter SRCBL K. Hen: you can spccify a com plete <lata block, e.B. DB \ 60 f)T "Areh>,e l. " "anable from a data block, or an ah.olute addc~ssed dala area as an ANY po;tlkr. e.g. P# DB 160 DBX I6.0 BYTE 64. The ' OlITCe rou;;! be a data area in th e wock memory. If\hc somee acea is smaller than the target area , the ,omce area is wr itten completely into the target area. The remaining bytes of the ta rget area ue fil led ",;th ~eros . If lhc source area is larg~ (han (h e target arca, the target area IS '1' written completely; th e remain in g byte , of the SoUrc e area Brc ignored. Yo u can ass i!(J1 Ihe roll"wing altrib "tes to the created data block "sing the ATTRIB parameter;
'>

must tirst be w rillen to a data hloek created in this way bdQrc t h~ data c an b~ r~ad.
The data bloch cr~ated w ith t~ SFC . 22

CR E AT D B and ~5 CRA Oil ar~ "nl)' pres~nt Tn work memory If a CPU diff~rcn li ate, bem'een retentive and non-retentiv~ work memory, lhe SFC 22 CREAT_DB ~realCs a ret~>y) li vc data block, and the SFC 85 CREA_ D H creates a dall' bloc k as specifierl hy the AlTR TB parameler. "Retentive" dala block mean s that is its contents are retaine<:l in the event ofa w a nn restarT/ho\ rc'lart (,~c Chapter 22.2.4 , " Retentivity"). T he syslJ,;m fu nction SFC 8S CRA_ DB replaces the SFC 22 CREAT_DB.

A <Ia,a block cre ated by the Sl:'Cs 22 CREAT_ DR and SFC ~5 CREA_ DR dues not change lhe checksum of the Ll.~er program. not even if it is WIitt~n or deleted again. If a data block created by an SI'C is i.mponcd imo the o m ine data mO!llig~mcnt. this has an influen~~ on tb e
ch~cksum.

In the even t of an ~rror. a data block is not erealedo the pam meler DR_ NUMnER paramet ~r i. assigned Z<.--ro, and an ~rror number i. output byRT_ VAL

B it O = "I" The dat<! block has Ihe Unlinked anribute . Following transfer to the offline data m anagemenl and reloading into the C P U, the <.lata bl ock ;s still on ly pccs~'IlI in the load
m~mo ry.

'" Bitl = "j" The d,ua block has the DB is write-pml(!ded in /he f' I..C a ttrib ute. Yo" can only read the val ue. of thi' dala block. '" Bit2=" I" n,~ data block attribllle. has the

H I.3 .2 Crellt ing a Da ta B lock In LOlld Mem ory


System functi on SFC 82 CREA_ DB L crcat"" a data b lock in Ihe load memory. As the data block number. Ihe syslem func lion take' the lowe'l tree numlx.'r in th~ numb~r band given by the input paramcl~rs LOW_ LlMlT and UP_ UMIT. T he numbers .peeiiied at these pommelers are induded in the number ba::ld , If bOlh v a lues an: the ,arne , the da la block is cre3ted with th is number. The numix:r of a data b lock a lready present in Ihc user program cannot be as<igned again, nOI even if the dala block is on ly presenl in the work m emory. The output parameler DB_h'l JM ,uppl ies the number o f the dala b lock ac.tually created , Wilh Ih~ in put parameter COUNT, you spedfy the length of the data b lock to be crea\ ~d. The length corresponds w the number of dala bytes and must b e an c"cn number.

Non Rei";,,

The other b its arc not "sed al lhe mom~nt , You can find funhe r infonnation on the b lock attribllles in C,hapte r 3,2.3. "Block Pro!X'rtie," System function SFC g2 CREA_ Dl:IL operates in ""yn~bruDous mode: you trigger lhe c re ation proce ss with S'b'l,al state "1 " at iu p "t parameter REQ . You mavonly access 'he read and written data are a, again when the Olllplll param~1cr BUSY has returned to the .ignal , tate "0", Creating does not call the associaled data block. n , e current data block is slill Ihe ""lid onc .
A data block is not cre ated in the e vent of an en'or. the output parameters are a>signed undefined values. and an ~TIo r mc",agc is out r ut by Ihc function val ,,~.

18.3 Sy.tem Function. for Data Blocks

18.3.3 Deleting a Data Bl(lck System function SFC 23 DEL_ DB deletes the data block in RAM (work and load memory) whose number is specified in the input parame ter DB NtJ1.1BER. The data block must not be open at the time, as otherwise the CPU will go to STOP. Data bloch created with the keyword Unlinked and data blocks on an Flash EPROM memory card calUlot be deleted with system function SfC 23. In the event of an error, the data b lock i~ not deleted and an error number is returned as function value.

18.3.4 TeSllng a nata Block System function SFC 24 TEST_DB provides infonnation On a data block whose number you spec ify at input parameter DB_NUMBER. Output parameter DB_ LENGrH contains the number of existing bytes. and output paJ1lmeler WRITE_ PROT indicates whether Ihe data block is write-protected. If the tested data block is only in load memory. this is indicatw as an error by RET_ VAL: the DB_LENGTH and WRITE_PROT parameters ne'e.rtheles. have the corre~t assignn"'nts. If the specified data b lock is not present in the CPU's work memory, RET_ VAL is returned

with W#I6#80BI.

'"

19 lJJock Parameters

19 Block Parameters

deB.
t> t> t> t>

This chapter d<:$C:ribes bow 10 use block: paramYou will learn how to
d~lare

block parameter5,

how to work with block partmcte1"S,

bow to initialize block parameters and how to 'forward' block: parameters.

Block parameters represent the transfer inler_ face oolWL-.:n the calHna and the called block. All functions and function blocks can be pr0vided wilh bl ock parameters.

block function. Example: You want to write a block as an adder that you can use 111 your proiram ~'eral limes with different variables. YOIJ II1ltIsfer the ,'ariables as block parameters: in Our example, three input parameters and OTIC OIJtpUl parameter (Figure 19.1). Since Ihe adder need nOI Slore any values internally, II function is suitable as the block type. You define a bloc. parameter a. an input parameter if you only Check Or load ;IS value in the block program. If you only describe Il bloc. parameter (assign , set, ",.et, transfer), you u!e an output parameter. You must always use a n illlout para meter if a block pammeter is to be both ched:cd and overwrinen. The Program EdilOr does nOI ched: the usc of the bloc k panullctcr:.

19,1 Block Parameters in Ge neral


19.1.1 Denning th e
8lu~k

Pwramcters

Block parameterS mllke it possible to parameterile the processing instruction in a block, the

.,,,,

Btock ty?!, name .

Fe 12 Nama : Adder

Parameter .

Pr~m

om

Ronutt
FI~ur. 1~.1

Eumple of Block P.ramctcrs

19. 1 Block Parameters in General

19.1.2 Processing t he Rlod< I'aram~te~


In the adder program, the names of the block parameters 'tand a, p lace ho lders for thc latc,t actual variab les, You use the block parameters in the same way as symbolically addressed variables ; in the program, they are called "formal parameters" You can cal! t~C "Adder" function several lim .. in your p rogram. Witb each call, you tran,fer o ther value, to tho adder in ,he block parametcrs (Figure 19.2). The values can be constant" operands or vari"bles; they are called "actua l p'''dmetcrs''. At runtime. the CPU replaces the formal param eters w ith the aClu,,] parameters. The first call in the example a dds the ContentS of memory words MW 30, MW 32 and IvlW 34 and stores the result in memory word MW 40 , The same block with the actual parameters of the second call adds data words DBW 30. DB W 32 and DBW 34 of data block DB 13 and slOres the result in data word DBW 40 of data block DB 14 .
1/ Fir" oall

MW30 -

-Adder" Num b_1 Resu lt MW32- Numb_2 MW34 Nu mb 3


~

r,

MW4Q

Actual parameter
II Second co11

Illock par.meter -Adder" Num b_ ' Result Numb_2 Numb

DB 12. DBW30

DB '2, DSWn _
DB 12 , DBW34

r-

D812. DBW40

ADD I
-M~

Numb_1 Numb_2

Memory Numb_3 -

19.1.3 Declaration oftbe Block Parameter. You define the block parameters in the declaration ,eclion of the hloc\: when you program the hlock. Figure )9.3 shows the declaration tables of a function FC and a function block FE. In addition to the b loc k parameter>< (IN . OUT, I:N_ OUT), you also declare the temporary local data (TEMP). the function value (RETURN) for fun ctions Fe, and the static local data (STAT) for function b locks. Only the temporary local data (TEMP) exists for organization bloc ks OB which arc neither called in the u,er program nor possess an instance data block. Default values are optional and are only possible for function blocks if a block parameter is stored as a value. This applies to all block parameters ofdemcnt"T)" data type and to input and output parameters of comp le x data lype. A parameter comment can al so b e given.

~m"m
ADD I MW3Q- IN1 MW32- _ IN2 M emory ~,.

'N'

'" 0'" '" ADD_ I '" 0"' -

R.... ult

Fum,.1

0"' -

"""""

II Second call

'"'
'" 'N'
ADD I -OUT Memory

'"'

ADD_bUT

-MW 40

DB 12. DsW30 OS 12 DBW32 Memory DB 12. DBW34

'"

ADD I -OUT _

DB 12. DBW40

'"

Figure 19.2 Block Call with Block Paramete..

19 Block Parameters

Fl2U r . 19.3 Empty Dcciarntion T.bles for

~unct i ons

Fe and

~unction

Bloch FB

The block parameter name Can ~ up to 24 ~haracters in length . II must consist only ofletlers (without nati onal characters such as the German Um laut). digits. and the underscore. No distinction is made between upper and lower case. The name must not be a keyword.

by specifying th~ data tYP<' and possibly a com ment in th e declaration table u nder RETIJRN and the n ame RET VAL. As data type of the fWlc\ ion valt.lc, all elementary data type, as well as the data types DATE_ AND_TIME, STRING, PO INTER, ANY and user-defmed data types UUT are p.:rmiued , The data typ es ARRAY and ST RUCT arc no! allowed. As the fir<t outp ut parameter, the function va lue has no spec ial role to play in the LAD or FBD programming language. It only g ains significance in the SCL programm ing language, where you can usc the block type FUNCTION as a '"genu ine" function. Here, a function Fe can stand in p lace of an operand in a printout: the function value then rep resents Ih e value o f th is function.

For the dam type of a block parameter. a ll elementary, complex and user-defined data types are permissible as well as the parameter types (see C hapter 3.5. "Variables. Constants snd Data Types"). ST EP 7 stores the names o f the h lock paramete rs in the non-executable section of the blocks on the programming device' s .'torage medium. The work memory of the CPU (in the compiled block) contains only the declaration types and the data types. For this reason. program changes madc to b locks online in the CPU must always be updaled On the programm ing device's data medium in order to reta in the original names , If the update is not made, or if blocks are transferred from the CPU to the pro_ gramming device, the non-cxecutable_b lock sections are ov~rwrittcn or deleted. The Program Editor then gcnerates rcplacement sym bois for d i8play or pri ntout.

19.1.5 Initializing Bl ock Para meters When calling a block with block parameters, you in it ialize the block p arameters with actual parameters, These can be constants. operands with absolute addresses. fully-addressed data operands Or symbolicall y addresscd variables , The actual parameter muSt be of the sarnO dala type as the block parameter. You must initia li?c all o f a function', b lock parameters at every call. In the case of function b locks. in itialization of individual block parameters or a ll block parameters is op tional.

19.1 .4 Dcd ara tion of the Funct Ion Va lu e In functions, the function value is a speciall y treated output parameter. It has the name RET_ VAL (or ret_val) and i" defined as the first output parameter, You declare the fu ncti on value

'"

1<;1.2 Foml,,1 Parameters

19.2 Formal Parameters


In this chapter. you willieam how \0 a~eeSS the block parameters within a b lock . Table 19.1 shows that it is possible to access block parameters o f elementary data type, components of an array or structure. and timers and CountC1"S without re>triction. Chapter 19.4, ""Forwarding" Block ('arameters" Access to parameters of complex data 1ype and of paramctcr types POINTER and ANY is not supported hy LAD or FBD. However. you can initialize acqu ired blocks or sys1em blocks that have such pararnc t~"T8 with the relevant variable. You c an find examples of this in the libraries "LAD_ Book" and '"FRO_ Book" under the program " Data Types" that you can download from the p(,blishcr's Web5 ite (see page 8). Block parameters with data type ROOL Block parameters of data type BOOL can be individual binary variables Or binary compo-

nems of army. and structures . Yo u can chec k in put parameters and in!out parameters wi th coutaclS or with binary box inputs. and you can iniluenee output parameters ~lld in!out parameters with b inary box Outputs . After 1he CPU has used the aetual pammct~r spec ified as block parameter, it processes the functions as shown in the relevant chapters. Bl()ck paramNers ()f digital data type Block parameters of digital data type occupy 8. 16 or 32 bits (all elementary data types e~cept BOOl.). They ean be indiv idual digital vari_ ables or digital components of arrays and structures . You app ly input an d in/out parameters to digital box inputs. and you write output and in! out parameters to digital box OU\pUIS. You exchange values hctv,:een block parameter!; of different types or different sizes w ith the MOVE box as described in Chapter 6, "Move Functions".

Table

1~.1

Accessing!:l1ock. ParameterS (General)

;
O~

Possible

,=,
type,
DT. STRIl--'G ARRAY. STRUCT In dividual binary components tndividual digital components

, ,

, ,

, , ,

yes

'"
M

,
,

, ,

, ,

,..
ye,

TIMER COUNTER 8LOC K ]C. BLOCKJB BLOCK_DB BLOO,_ SDB

, , , ,
, ,

". ,. ,.,
yes

,"

0" 0"

J 9 Block Parameters
B lock parameter. of da ta type COUNTER You can use b lock parameters of data type COUNTER with all functions as described in Chapter 8, "Cowltcrs"'. When setting a counter, the counter v alue can also be a block parameter of data typ e WORD. B lock parameters of dat.a type BLOCK_ DB You can transfer a data block via a block parameter of data type B LOCK DR Call this data b lock w ith the OPN coillbox by lalx:ling the OP;:"! coil/box with the fonnal parameters . When opening a data block via a bloc k para meter, the C PU a lway, uses the global data block register (D B re gister), Bl ock parameters of data type BLO CK_Fe You can traIl5fer an Fe function via a b lock parameter of data type BLOCK FC Call this function with the CA LL ~oi llbo; You can uSe the CALL coi1lb o~ with a formal parameter and w ith or w itho ut any preceding logic operation if you are currently programming a function b lock , If you usc the CALL coil!bo~ witb for_ mal parameters in a function. a preceding logic operation is not permissible (ab~olU1e call only). An Fe fu n cti oo lranskrrcd via a block parame ter must not have any b lock parameters. Block panmeter. of data type BLOCK_FB You can transfe r an FB function block via a blo<:k par.mlctcr of data type BLOCK_ FB . Direct aec es< to hlock parameterS of data type BLOCK]B is not possible wi th LAD or FED functions , An FB func tion block transferred via a block param et~r must not have any block parameters. Block parameter. o f data type PO INTER and A... "'Y Direc t acces , to bloc k parameters of data type PomTER and ANY is not possible with LAD or HH) f unctions ,

B lo(k param,'len of data type DT and STRING Direct access to bloek parameters of typc DT and STRING is not po>s ible. In function blocks, you can "pass" input and output param~ters of data type DT and STRING to parameters of ca lled block. Bl ock parameter. nf data type A R R A Y and STRUCT Direct a~CeSS to bl ock parame!= of type ARRAY and STRUCT is po,sible on a eomponent_hy_componcrtt basis, that is, you can access individual binary or digital components with th e relevant operations, Access to the complete variable (entire array or entire strucrnre) is not possible and neither is access to ind ividual components of complex or user-defIned data type. In fimction block" you ""n "pass" input and output parameters of data type ARRAY and STRUCT to parameters of called block!; . Block parameters of lI~er-deflncd data type You handle block parameters of user-defined data type in the same way a~ b lock parameters of data Iype STRUCT. Direct acceSS to block parameters of data type UDT i ~ possible on a componcm-by-eomponem basis, that is, you can ~CCeSS individual binary or digital compone nts wi th the relevant o\X-rat ions Access to the complete variable is not po,sible and ne ither is access to individual components of complex or Ilser-ddined data type, In function blocks, you can "pass on " input and oUlpm parameters of data typ e U DT to parameters of called blocks . 810ck para meters of data type TJ:\IER You can uSe block parameters of data type TIMER with all functions a s described in Chapa-r 7, "Timers', When a tim er is stmtcd, the time value can ,,],0 be a block parameter of data type SS Tl.ME.

19.3

A~tua l ParaJT1ete~

19.3 Actual Parameters


When you call a block, you ini tiali~e it, b lock parameters with con>!ams , operands or vari_ ables with which it is to operate. These are the actual param<:tcrs.lfyou call the block often in your program, you usually USe different a ctual parameters each time . An actual parameter must agree in data type with the block parameter: You can only apply a binary actual parametcr (for e:-;amp le, a m em_ ory bit) to a block parameter of type BOOL; you can only initialize a block panuneler of type ARRAY with an identically dimensioned array variable . Table 19.2 gives an overview of which operands you can use as actual parameters with which data type. When ca lling functions, you must initi alize all b lock parameters with actual parameters. When callin g fun ction b locks , it is not a manda_ tory requirement Ihat you initializ e b lock parameters with a~tual paramet"rs.lfyou make uo specification ala b lock parameter, the (old) values stored in the instance data block are used as the actual param<:ters. These can b~. for example, the default va lues Or the valu es of ""tual p arameters from an earl ier call. In/out parameter. of complex data type ~annot be assigned defau lt vailles, and neither can parameter types . You must provide these block parameters with actual parameters at lea,t allhe fir.t cal l.

You can also use d irect access to aeees~ the bl ock parameters for the fu nction b lock. Since they are located in a data block, you can handle the block pararn~ters like data operand s . Example : A function block with the instan~e data block "S/a/ion_l'" controls a b inary output parameter w ith the n ame '"Up '". Following processing in lhe f" nction block (after its call), yo" can ch~ck Ihe parameter under the symbo li c address " Sla lion_ t".Up, without having ini_ tialized the output parameter. Initlalizlng block paramet ers with dc mcntary data types The actual param~ters lisled in Tab le t9.3 are permissible as actual paramcters of elcmentary daUl type. You can assign either ab solute or "ymbolic addresses to input . output and bit memnry operands. Input operands shou ld ~ used only for input parameters and output Op<'rands for OUIp"t paramete rs (however, this is not mandatory). Bi t memory operands are suitable for all dedaration types . You must apply peripherat inputs only to input parameters an d peripheral outputs on ly to output parameters. You use the 800lean constants TRUE and FALSE in LAD and F130 10 sct defaults in the de~ l aration of block parameters, static local data or dala operands . Initializing block paramete~ with thes~ const~nts ; s not penniued. You also cannot Create these con . tants at n contact ( L AD) or at a function input (FBD). If you want

Table 19 .2 tnitialization with Actu~l

P aram<t~f"

"

Cornponetlts of arrays or

,tructur~ S

of ~I <men tary data I>'pc

"

Block parameters o,thc cal ling block

19 Sloek

ParameI~r1

OUlput$ (proc<'ss ;ma~)

, ,

, ,
<

,
,

,., "
Qy.x

"

:-t

<

<

,
<

DID

Compl= component name

"

to initialize block pan"nc\~rs with TRLc or FALSE, you require a variablc that ;s pennanenlJy ass;gne<i signal ,tate "1" or "0" and thaI you usc instead of the Sookan con'lanIS. Bil memories are obvious candidate3 for "ariables ill th is..,.....,.. The following example shows)'ou how 10 SCI a bil memory pennanenlly 10 signal Slale "I" or ''0'' &1 Slartup. see figure 19.4. Parl-add",ssed dala bilS an: nOI pcnnissible as actual parameters in LAD and FBD. The reason for this is Ihat the Pro!;ram Editor transfers the signa I state of every binary actual operand to a temporary local dati. bi t prior 10 Ihe a"ual block call. For Ihi~ teuon. it is pos.iblc in LAD 1lIld run to initialize a binary block: input wilh a log;"; operation. Dunng copying before the block: call. the u~ignment oflhe dala block 10 thl; dala bil il los\. Even if you open the "correct" dala block in the proiIllm of the called block prior to aCCe8J;inll Ihe block parameler occupied by a partially addrcslcd data bil, only the previously created copy of the 'ignal Slate will be scanned. The same a""liel 10 binary in/oul paramet('TS and OUtpUI paramet('TS: here 100. asSignmelll with part-address! dala bil$ is nOl pennissible (the Progntm Editor will not reje meh an Msigl1lnenl bul in most cases ;1 will result in crrored functions).

When I.Ising part-addressed data operands at dillital parameters. you muSI note thaI when ~~e~ssing the block paramelers (ill the called block), Ihe currently opened dala block is al!:O Ihe "co""ct- data block. Sinu the Editor may in ccnatn cin:umstanus. lucb as during a block: call or if the block paramcll'I1I have previously bn acces.>ed, nOI visibly elumge the dala block:. the use of partially addressed digilal dala operandi is nOl recommended. Use only fully addressed dala operands for this rcason.

Temporary local data arc usually symbolically ncldress.:d. They are located in thc L Slackofthc calling block and arC declared ill the calling block.

1 '''''If -' ------'-"-'''"''"''--1-" -1 '--' 1f' --'


, (R

811

BilmX.y

flj;urr 19.J lniti.li,ation WI'"

F i~.d

Signal StOle

19.3 Aeroal P8lllOleler5 If the calling block i. a function hloc k, you can al r.o U.<e it' .ratie local data,,~ aeruall'arameters (see Chapter 19.4, Fvrwurd ing Block l'an'met"'l"S"'). Static data are u~Llally 5ymboli ~ $Il ~ addressed: if you would like to a~sign . 0solulc addrc%cs via Dl opernnd~. please note the informal ion in Cba~er IS .2.4. "SpeeiaJ 1'0;1115 In Data A~f08ing. W ith a block parameter of type BOO!., youean apply the constant TReE (signal state "1"') or FALSE (signal .tate "0"), Hnd with block p~mmcters of digita l data type, you can appl~ "Jl CVll.t~nlS corrcspondinS t<> th e data t~pe . Initiali/ation wil" eO""'tams ;~ r-errnis,ible onI~ for input I'arameters. You can also initialize a block parameter ofele mentary data type with compooenll< of arrays and 1\CU~tllICS if the componCltt IS of the same dat.a lype as the block parameler.
I nlt h.lbin{: block parRmctcr~ of complex data ty pe

I nlthll111nlil block parll.n,etu, of UHrdefine d dM la IYJK"" Por complex or eXlcn si~ c dalll SlruClnrcS. Ihe usc ofllscr. defined data types (UDT." i, I"ommended. First, you defi ne th e UDT and Ihen you u~ iI, for example, 10 generale the variable in Ihe datM block or to declnre the block parameter". You can \hen 0""' the variable when initial izmg the block parameter. Here. tOO, the actual pammeter (the variable) must be of tbe samc da!a type (the same as thc hlDek parameter.

VOn

A complete data block with the .ame UDT type as the bJocl:: parameter is nol pcrmis~iblc ., actuul parumeter.
Jnltlali~in\: block p anmctc" of type TlM"F:R, C OU:'<;T.E:R a Dd BLOCK_II

Every block parame ter can be of the evmp le.x type. Vari"b1cs of the .ame Iypc can be Il.'led as lelUIII OpCrands.

You mitiHli~e a block panmcICToftyPf' TIMER with Ii timer and a block parameler of type COUNTER wilh a counle r. You can apply only hlock~ without their own panlmetL"Il< Iv bluck. parameters <>f pammetu types I:JLOCK_f C und I3LOCKJR. You iniliulizc BLOC K_DB5 with a data block. Block paramctrnl oftypcs TIM ER. COUNTER and B LOCK_x~ must be input paramelers. Inltllilb.in2 block paramete" nf type POTNTER Pointers (constanls) and opr""o,ls arc p<:rmi .. i. ole ror block parameters of parameter type PONIT:R. The se pointeili are either rang~ pomters (32 -hil pointers) or DB pointe", (48-bit pomters). The opcnmch ;ore of dcmcnlary dalll type and can also be full~-.ddrcssed dat.a operands. Output parameteTh of type I'O INTER an: not permitted for func tion blud s.
InIlIDl1~lo"

For ini tiali7.inl: block parameters of type DT or STR ING, in dividual variable~ or eomponems OfBITII}'$ o r structures oflhe same data type arc
penni~sible.

STRING vari ab les can be of vuri"ble length. If you have ~l'ec if,ed the STRNG Icn','lh when deda ring an input or vUlpl:t pbrameler for II function block. the Editor rcserV(:5 the specified space in lhe instance data block; if you ha"e not ~pecifitd any length, 256 byles are resen-cd for Ihe STRIt'G variable. The ma.' timum length of the STRJ!'IG variable. wh ich you specifY in the d'Xlurution, mll,' be th~ same for the actual parumetcr and the rorm~ l parameter. Exception: Wilh Fe funclions . you spec ify eilher no length or the standard lenglh of 2~4 bytes when declnring a ST RING variable: h~re, yon can use ST RING variables of all kllgth~ lIS aemal pnrnmetel1i'. f or initializing block parameten of type J\.R.RAY or STRUc..'T, variable.'! wi!.b exactly tbe "",ne structure IlS the block parameters arc pemllSsibl e.

block

parameter~

of

typ~

ANY

Variable.' of all data types arc prnni,sible for block parametcn; ofpanuncll"T Iype ANY. The progmmrniog within the I;l<lk-d block detcrmines which variables (operanlh or data types) mo~t be applied to the block parameters, o r "hich variab les are feasible. You ca n alsu 'peeif;' B constant in the formal of the ANY poinler

1'Iobl< 19 .. PcnniMiblc Cmnb'""t'''''' wh= Forward,"lI Block l'acameI=


' . 11inr.:.'>' caned !Xcbral'o" t)'p< Inrut _ Input
Outpul > Outplll In/OUt _ Input In/oot _ Outpul In/Old _ lI'IIout
C
~Ic" ... _ y

,
, ,
,
,

Fe ,ails Fe
C

, ,.flJ enll. , ,
Fe

Fe caUs HI

, , , ,

, ,

, , , , ,

,
,

FB calli FR.

'-

<!au 'YP<'

, ,

, ,

, ,

.. ,

<.: - c.....,1....... ."...


1 ' - ~_'J'1><'o

TIMER,c:OU(H.R .... BU)"' ,," ""

"P#[data blocl<'}O!'eflmd Data!)-pe NWIlbcr" and thus define an absolute-addr..,;sed arCli.


O"lpUI parnmctcrs "rtype ANY an: nOIJl'"rmusible for funclion bloclcl<.

Block paramelers of puramctcr types T IMER. COUNTER and I3LOC t,Uu can only be pa.~s.ed on from one inpul p3ramel~r to aTlOlber if the calling bloc!.; is a runetion block. Thc:$C IUt ..ments an: represented In Table 19.4.

19.4 "Forwarding" Klock Parameters


"Forwarding" bloc!.; paramtle~ i. a 'p"dBI fonn of aC<:CSS and of initiuli.zi.og bloc.!r. p"mmeters. The bloc!.; paramet.. rs "fthe calling bloc!.; are "forwarded"10 Ihe paTllm~tcrs ofthc called bLock. The formal param~1~1: of the calling block then bccome~ the a~llIal panuneter oflhe ~ B Hed bloc!.;.

19.5 Examples
19.5. I Con "e yor Hell
F.l~ n' ple

The example shows tbe transfer of signal states

In general, il is also the case hel'<' thaI the actual parameter must be of the nme type a. the for mal paramet ~.,- (thai i~, Ihe relevant block parameters must agree in their dala type.). In addition, )'OIJ e~n apply an input parameter of the calling bloch only 10 an inpllt parameler <.>f the called block, I.tId simi larly. an on!pUI pamuleter 10 an nUlput p.a.ratncIC1'_ You can appl)' an h\l'out paramctcr of th~ calling block 10 Bil d~c1aration types of the called block _ There "re restrictio". with reg"rd to data type. caosed by the variations in the SlDrage ofbJod parameter for funct'ons and those for funclion block . Block parameters of elementary data type can be p>ss;;ed on without "-'<'tricrion in accordance with the ",formallon in the previoos puraamph. Input and output paramelers of~om' pl~" typc can only be foowarded if Ihe caiJillll block is a function block.

VII block. paniIIleten. For this porposc, w~ Il$C Ihe fiwction of ~ C<.lllve-)'or belt ~'01Itrol syslem described ill ChaptC1' ~ , "M~'Ttlory Funcrions The conveyor bdl control ~ystcm i, to be programm~,.j ill a (unction block. nnd all input s and OUlpUts are to be route<.! through block I'armnclers so th"t the function block C"tl be call ed repeatedly (for severa! conveyor bellS). Figurt! 19.5 .how, the input aod output param~lers for tile function block. as welluthc "w.tic and tern porary local data uSC(!,
R

Distriboting the parameters is quite <imple in this case: All binary operands tbat were inputs have become inpul parameter., all output, havc be<=ome output parameters. und all memory bils have become "atic IOCBI dut". Yo" will al50 hal'e noticed that Ihe names have ocen altered sliaht!y be<=alL.e only lenet!l. digi~, and Ihe un(!er$core Ilf~ permined for hlocl.:;.Iocal van_
ablc~

The function bloc!.; "Conveyor_Belt";$ 10 e<>ntml tv.o e<>n'-cyor belt!. f or this purpose, il will be cal1.-d Iwiee; Ihe 11rst time wilh the inpulS a~d OUlputs of conveyor belt I and the second

""

19.5

E xamp l~s

FB "Conveyor belt"

19 . 5.2 !'ar ts Co unte r :xa mp le


R ""dyIo.1od
R~ady_r ..." B~._mot

"=, ,=, = ,=, ,=, = =


'OQ eOQ

c.,.-,U oo"

~"

B8,,"_,t
,~

Man_oo

f=

BOOt.

En'U,oIt M fault
STAT
Lo ~ d

RornovQ EM_ R . m_ EM_Rem_P EM_ Lo.o_N EM_ Loo_P TEMP

PM_Rom_P PM L"" P
F I~u ,.., 1 9 . ~

,= ,=, ,=, ,=, " ,= ,=, ,=, ,=

The cxampk dcm01]Sltates the h andling of block parameters of ~I~mentary d ata type . ~ Parts Counter" cxample fmm C hapter 8, Counters", i.' the basis of Ihe func tion. The s ame function is implem~nted here a" a fun ctioll b lock, with all g loba l v ariab les declared cilher as bloc k pamm <:"',.,. ur as stal ic local dat a . T he lime,.,; and counters arc contro lled here v ia individual elem ents. Timers and COllit ... ,--s arC transferred via block paramet~" of type TIM"ER and CO UNTER . The se block parameters m ust Ix; input parameK.,-,;. The initial value, o f Ihc ,ounter (Qua,,'i!),) and the timer (Dural and Dura2) can alsu be trans ferred as block parameters; the data types of the block parameters correspon d here to those of the actual p arameters . The edge memory b its are stored in the stat ic i<x,d data and thc puhe memory h its are s tored in the t~mporary local data.

F Wlc, iun lJlocl< for 'he Convc'Yor Bolt Example'

tim e with those of conv~yor helt 2. For each call, the fu nction block require. an instance data block where it stores the data for the obta ining eonv~yor belt . The data block for conveyor belt 1 is to b e called "Beh Daml" and the d"ta block for convcyorbelt 2 is to be c"l1~d HcltD ata2"'. You cau find lbe cx~...: utcd programming ~xam pie in the library "LAD_ Book " Of "FBD_ Bool<" und~.,. the program "Conveyor Examp le -- that you can down load from the pub lisher's W~b,ite (see page l\). Tt shows the program ming of function block FH 21 w ith inpm paramNers, OUtplll parameters and static local dsts . You can use any data blocks a, instance b1<x ks: in the ex ample, OH 21 is used fur 'Hdt_ data j " and DB 22 fOT "Bdt_ datal', Tn Ihe Symbol Table, these data blocks have the data Iype of the funClion block ( F ]{ 21 in the example , if "Conveyor_beh" i.the _ymbol for FB 21). When you cal1 the func tion block, yuu ,an u8e the inputs an d outputs from (he Symbol Table as actual parameters . In lbo, ... casc, where these global symbols conlain sp~cial characten;, you must pla~ e th ........ ymlxl ls in q'lOtati<m marks m the program. Th e Symhnj Tahk i, dcsib'1lcd for all three examples in th is chapter (fable 19 .6 at the end of this chapter).

You can fi nd Ihe ,ample program in the li brary " LA])_ Huok-- or "FBD_ Book'" umk r the progmm 'Conveyor Example", lhat you c an download from the publishers Website (see p age l\) . It con tains fUD ctiou block FB 22 "Parts counter" and the as.oci at ed instancc J ",,, block

COUNT ER WORO T IM ER S 5TIM E S 5TIM E

,=, ,=, '" ,=, lbanier

FB"P "" Ac krK>w1


~m

=
= =

F.';"r..d
Fau ll -

Ou. n tlt~
,~ ~. ,

Ou",2

STAT EM_ LB_ P EM_lB_N EM_AC_ P EM ST P

,=, ,=,
,=, ,=,
ElOOl e OQ
,~

eoQ

T E MP PM_ l B_ P PM_ LB_ N ' _ BOOl t S5T IM E

S5T IME

FI>!UN 1\1.6

Function Hinck lor the Pwts CQuntor Exornplc

'"

19 Ulock Parameters ''CoumOal''. You can \1.: Ihe inputs. OUlpuU. limer and oounl~r from the Symbol Table (Table 19.6 in previous example) as actual panom<.'Tcrs ",hen calling the function block.

trol all ':O;1>"eyor belt, via B05,e31, Man 011

and SlQP.
The following program fQl" fUneli on block Feed' is de'igned in the same "" y. Thc input and outpUt parameter.; ot"the function block can be taken from Figure 19.7. I" addition. the dig. ila l valu~, fo r 'he pan . counter Q,umlil),. {)~r~' ~nd [J"ral are designed as input parameten hel"<' , We declare the data of the individual con veyor belt controls ami the data of the pans cOunter in t1J.e slatic local data in exactly the same way as for a user-delir>eo;!. data ~, i,e. wuh name and d3ta typ<". The variable Belt l~ is '0 receive the data .trucrure of funcllon block -COIl\"e)"or Bel:', as is variable "Belt2~, ~tc.; the ~ariable "Check~ 1"C<:eives the dala stroCIt.ll"<' ofth~ funetion block 'Pans_counter" .
The program ill the f\.ouction block ~Ians with the initialization of the ,;gn~ls common to all conveyor belts. Here, we make Ui~ of the flltt thu, the b lock parameters of the function bloch calle<.! as local ill~tarn;c. are stat ic loca\ data in the e um:nt block and can be lIeuted u sucb. b lock parameter M,m 'III in th. current funL1ion block controls ihe M~" on input paramcters of an four conveyor bel! controls with a singlc a"ignmenl. We proc:ectl in the :.ame way wim the SIgnals SlOp and Resel. And no,,- thc conveyor belt controls an initialized wi,h the COmmon .ignaI8. (You can, of ~"(>ursc. also jnirializ.:: These input pe.r&met<TS when the func,ion blOCK is c:alled.)

19.~ .J

Feed Example

The ~anw function' de, cribed in the twO previ, oui exnmpleli can al$o be called as local instarw;u. In our example. !hi. mccans tNt we pl"Ojr&m a f\.orw;tion block called "Feed' mat IS 10 control four conveyor belts and COUDT the con"e~ pans. In this function blod:, FB "Conveyor Belt" is called four times and FB PartS_ counter" is caLled once. The call doc, not take place in each ~ with ill> 0"'''' instance data block, bm 1m called FBs are 10 SIOK their data in the instanc<: data blockof~liQn block feed.

Fiaurc 19.7 shows how tbe individu"l conveyor belt controls al"<' interconnect ed (FB Pans counter' is not represented here). Thc start silO' n,,1 ;~ conn""tcd to the SW'I input of the con troller for belt I. the "'tidy_rem output i~ con nected to Ihe Sum input ofbeh 2. elc. Finally. the ready-"em output of belt " i~ conne<:led 10 the R~m(J'Ift OUlPU' of -Fced'. The same sianal sequence leads in the l"<'\'ersc direction from Remo>I over Conl/nue and Reodylood 10 Lond.
8(41_",(>/, L/)(,Irr and IMjauil a~ . epanne eon ~eyor btolt 5ignuls; R"5"', Stanup ao<l Slop con-

n'e

FUnclloo blo<:!< 'f...o""

!I.Ir.... ~1
L ~""1

-...
2"

19.5 Examp le.

Tahle 19.3 Declaratiun Section ofl'B 'Feed' '. p""lara}bme StOTt


R"",ovcd

-lion

M dre<.'
HOOL

tni',aJ
Val"" FALSE

. Comment
Stan co nveyor he l"
Part< have boon removeu truml>eh

...

." "
"

,.ill

BooL
D~L

,.
" " '.0
0.'

,.,

....

:;;'J

..
t

L. ".

\fan_'tart Stop
Re,et

BooL BOOL
COUNTER WORD
"]"l \l~. R

FAl.SE FALSE FALSE FALS F


W # I6#200

Stan C (mv~)'N belts manually Sl(}p ,',mveyor belt, Set control to the ba,ic ""ning
Count~r

Count Quantity Tim Dural Dura2


Lo ~d

lOr the part'

I 4 .0

.Numbc:Tofp~tt.

S5Tl/I.IE
S5TnfE

"

"'

S5Tlt5S
SH"IQS

10.0

Timer forthe monitor :'fo~ j torinii. ,jme fo r part. Monitoring time for gap
Load new parts 0010 helt

om
r: N~OUT I
STAT

Remove Bcltl Belt2 Belt 3


Bd!4

BOOL BooL
Conveyor_ be lt c.:m",:yot_bc lt CO!lveym bel t Conve yor belt
1' ...... counter

FAL SE fALSI::
14.0 20.0 26.0

Hemove parts from belt

32.0 3R.O

Check
TEMP

Control for belt I Control toe ~ It 2 Control for belt :l Control for bell 4 Contro l fo r counting and munilming

The sub,c'luent call, ufthc function blocks for eotwcyor b elt control contain on ly th~ block panomelcr~ rUT the in dividual signals tor each conveyor be lt and the connecti on to the bl ock param Clers of '"Feed'". Th e indiv idua l ,ignal~ are thc lighl barrioN, lhe commands for the belt motor and the motor faults . (We make use here of the fact tm t whl.-'Il" function block i" called. not al l block parameters have 10 be init ialized .) v,,'e program the connections between ~he individual belt conlro llers u,ing assigmnenls .

Thc fB "Pans c ou nter'" '" called a., a local 1n s\an~e even if it has no closer c onnection with the s igna ls of the conveyor belt controls. The inStaJ1CC dala block for '"Feed" stores the t'B data , The input raratnClCrs Quanli/y, Dura! and Dura) jor "I' e~d" nc<:d to be set only Ollce , Thi s can be done u.,ing detimlt values (as in the example) o r in the re smn routine in on 1()() (tor example, through d irect "",ignmenl if these three parameter> arC t.-cated as global data).

263

19 Block I'aramc{crs

I #Ma!-f__"-,________________________'_'~ '~Ma)"--oo_1 __
#Be~.Mall_on

IIBeltJ.M9

ItBel\4.Man_0Il

)--I

~of'---,--------------------------'-'~eltl ~
#Beltl.Stop

e - -e -L--_

- - --{)--I

- -- --{ )--I ,

#Be~3.S{OP

II'B@it4.S\op _ _ _ _ _ _--{, )--I

~ef~ :..-__,---------------'~'~'~'~"_{BaH ~'

f-_____________' '.~'~:,:Ba~ ~~ O f-______________~'~'~.~"~':,: .Ba~


L._ ___ _ ______ ___~ '~.~"~ '~ ',:B9H

1------1"

ItBel! !
Ro~dyload ~ #load

" ''" f--H----1 """

#Bel{ l(fl_'_'_"'_'_'________________________'__"~'

tH

;r;Belt2SU>rt

( )--I
tlgurc 19.8 Program for he<l example (LAO)
Con,jnued overleaf

19.5 I::.umpid

e"",/n"N:
IIB.1t2

.,"lMfa>lll2"

'"
End_belt Mfeu lt

'NO
ee~_mo l

FiK.. ..., I'.s


~m

for FC<."<i Example

"B'~_rnot7"

(LAD)

I1t8ett3(Qadyi<n<l

f-I- ' - - - -- -- --jl

"B~t2.ConIinufl
_3.Stool1

)--I

IjRIlady-rom f-I-"'--- - -- - - - i l )--I


.. eeN3
'N
.~.

'NO

"lMh"'~"

.,

""'-Mfault

'"emo<
- --

_ __ mol)"

l",eelt4te~dYload

f-I- - --

---<1

#8eH3 .ConUnU9

)--I

1'8.K4

"
Conbnue
End_bell Mfau lt

'NO
Rncl)"-,,,m
Bait_mol

r-'R~

"lbalY4"

"lMfaul14"

f--'

.."t.berrt"

~- ,

"

'"0

"',
lbolrri.,.

,,- rFeuN

"FlnItllacl"

~~

r-

' FauII""

""""" - ""'. """"'" ~

OtOu<e1 #Oura2 -

-- """"" """

M.lan~ .tar1

IIBNll .Man.-,)n

# Belt2.Man on

#8ek3.MaR_on

~.Man_on

IISiop

/l'8e1t1.Stop

#Belt2 .Stop

IlBeIt3.Stop

llBe1t4.Stop

#Reset

IiBen1 _ Bnlc_,t

#8eIt2.Ballc_11

.Bett3.BIoalc_u

ItBelt4 BIollc_u

/t6e ll t

"'Loom "
"/MfauIt1

""'"

"'"
----i

En<C~t

Rudyload Bell_mot

"-~,
~LmoW

MfauH

118e1t2_lWadyIoad

,
,
Exampl ~

1l'8e~ 1 .Conlinue

I I

1IB<IIt1.R&ady_rem

---1

IIB& rod2.Start

(FBD)

FIKIlI"e 19.9 Progn.ru for Fd


COlt''''~~ o ... ,,./~af

26'

#8 ..,t2 "/ M/au lt2"

"Lbarr2":=~;';";'~_;O:.:___':.:':'~m:oj~ 'Be~_mot2" t Mfault "


---1
#Be1t2. Conliflue

#Selt3 .R&adyload

80

# Selt3 "fMfault3"

"Lb",,3"
--1

E~d_b9~

Beicmot

Mfault

118..113. Continue
&

#aelt4 . Re~dytoad

#Band4.Start

#Removed "Lbarr4 " "fMlault4"

#B@ lt4 Ready rem Continue Belt_mot End_ belt Mla ult

#Remove
'a9~_mO t 4 '

#Start "Admowl" "Lba rrl" #c<>unt #QuanUty #TIm -

~~jset

"'~,

Ack~oV>1

Finl~hed -_ Fault

"Fin ished" "Fa un"

Lbarr\er Cou nt Quantity

#Dural -

Tim Dural

#Dura2- ': ',, -_ _ __ _--l " C


Co~II",,~d."

figure 19.9 Progt"Um for feed I::xomple (FBI))

'"

19 1llo<:k I'lonuneCen

T.bl~

111.6 Symbol

T.bl~

r..... lhe COI!,eyor tielt. PIU"1II COWlter ~nd F~ Example>

." "

conveyor
com.yor

" "

"j

"

, "

'"

Program (',"""cssing

Program Processing

This section of the book discusse s the various methods of program processing. The main program executes cycl ically. After each program pU>s, the CPU rerums 10 the beginning of tb" progr<tnl and e "ecUle, il aga in, Thi, is the "standard" method o f pro~e,sing PLC programs, Numcrou..> system functi()ns suppon the utiliza tion of ~yst~m gervices, such as conlroliing the rcal_ lime clock or commun ication via bus sy,,lems. In COntra,! to the static se!lings made when parame lcri/jng the CPU, system fun~ tions ~an be used dyn amical ly at program run nnw. The main program can he temporari ly 5U<_ rended t() ali()w interrupt .crvicin g . The vari om Iypcs ()f imcrn'pts (time-of-day imenupts, time-delay intctnlpts, watchd[)g interrupts, hardw"re interrupts, DPV I interrupt', "ynd1T()n OU8 cycle interrupts. muh;pro~c~sor ;mcrrupt) are di vided into priority classes who<~ processing priority you may yourself, to a large d egree , J~termine. Interrupt servicing allow s you to react qu ickly to .ignal, trom the controll e d pro_ cess or implement periodic control procedur~ , ind~pendently of the process ing time o f the nla,n program, Before starting the main program, Ih c CPU ini tiates a stllrt- up pro;:ram in wh ich you can make ,pcc ifkalions n:garJing progmm PNccssing, detjne default values fo r variah lc s, or parameterize modules, .Error handling is also part of pro1,'tam p ro_ ce,sing. STEP 7 distinguishes between synchro'J<)Us errors, which occur during prlXcs>ing of a statement , and asynchrouous errors, which can b e dc\cctcd independently of program proc~s"ing . In both cascs you ~an adapt th~ error routine to ,uit your needs

20

.\-hln pro;:rllm Program "tructure; scan cycle contr()l; respon>e ti m~: program functio"",: mu!!i computing ope ration; data cxch&ngc with system fun~tions: start information Interrupt handUng

2t

Time -of_day interrupB; rime-Jeta)' ;tHerrupl,; watchdog interrupt': hardware interrupt>;: DPVI interrupts; multiprO'-'cssor int<-"rrUpt; "ynchronous cycle intcrn 'pts; h andling interrupt c"~nL' 22 Stut -up characteristics Power-up, mcmory rcscl, retemi v ity; cold re,la!1 ; warm l'e<turt; ascena;n module "ddr~s", parameterize mod !!les Error handlin;: Sy nchronous errors (programming ~rro"_ acces, errors); handling synchronous elTor evems: asyn~hronous ~rror'; sysl<-'1ll Jiagnwtics

23

'"

20 Main Propm

20 Main Program

The mnin program i. Ihe cyclically scanned UK!" prol,:ram; cydic ,canninll is the "nonnal" way in w!>ieh programs exCCUlC in progrnnuna1>Ie logic ~ontrollcrs. The large majority of eOnINI sy~tcm' u.<c only Ihis form of program ex~ cut ion. If eveUl-driven prog.nun ""anniD. i~ used. it i$ in must C<lSCIl only in addilion to the
main pT'Ognirn.
Th~ mll;n prol,:no.m is invoked in Of1j:ani;alion hlock 00 I. It ..xc:cUles al {he IU"'esl pnorily level, und elIn be interrupted by aU olh~ IYPO;:' uf program processing. Thc user program u executed in RUN mode. which is sci usinlo1lhc mode seleclor on the CPU', front pane\. With a 1<.>lUIlc .wilch as mode selector, the position i. II. UN, wilh a kcy_operat.-d .wi t~h , the positions are RUN and RUN -P. When in Ihe RUN-I' position. Ihe CPU ean be programmed via a programming device. In Ih .. RUN po~ilion. you can "'IOOVe the key ,;0 thaI 00 One can chanae the OJl'C'3ting mode w;lhout prop<.T nuthonzsllon; when me mode .eleclor is at RUN. proll"'JIl$ can only be read.

uocr p.ograIl1S). And finally, bUI not lacking in imj\OTlanee. (lividing the prolP'am .implifies both debugging and service Dnd malnlennn~e

The .trucruring oflhe 1,lS~1' program de~nds on il8 si/c and its function. A dislin~"\iOll is made betwe ..n th.-..c different ""mcthods":

In a Unear progra m, Ihc eudn: mam program i. in organirdlloD block OH I. Each eutTem
patb is in a S(Cpa1llle DeNo'Ork. S11'P 1 numbers the nL'!works in sequrnL~. When editing nod debuggmg. you can refe~nee e~cry nctwOTt.: dircclly by ils number. A pani tioncd progr'im is basically n linen r pTOIr"'im which is divided into blocks, R~"sons for di\idin g me program mij;hl b~ b<:e~u>c it is too long for organizalion block 011 I ()T bccaLloc }OU ",anI 10 mak.. il mon' relldable. The blocks are then called in .equence. You Clltl ~ISQ Ilividc the program in anmher block lhe same way you ",ould Ihe program in organi.tatiuu block OB I. This rn.-rhod allowl yuu 10 call associaled process-relaled functions rOt procesling from within OOe and the same blod. The a,dvanl8aC of this program siruciure is tftal, e'en though lht: program is lin...r. yoo can sfill debug and run il in sections (.imply by omitting o r adding block calls). A Slruclnred p~ullnm is u!\Cd when Ihe concepn," l fo rmulation is particularly extensive , ". hen yuu want 10 ,eu~e projp'Ulll fun~tiuru;, or when complex problems must be soh cd. StrucTUring means dividing the program into S~Clions (blocks) which embody self-contained funeI;on< 0.- sen e a specific funCI;on.1 purpo5C IItld ....bich e"'change thc fewe.ot po$sible numbcr of sipls with other blocJts. Assia,nlllg each program s..-crion a specific (proeHI-relaled) fuDC_ I;on '" ill l'f'Oduce easily r<:.w..blc bloc""" ",ilil simple int.. rfaccs to ,,!her blocb ...hen projp'UTDmcd. The LAD and run prugranuntng language. support strucrured programming through fun~_

20,1 I'ro&:rllm Organization

20.1.1 Pru\:rJlm Structure


To nnalyze n co mplex automation task mClm" tu divide Ih~t task into s!IL~lIer tasks or functi(ln~ in accurdancc wilh Ihe SlnICtun: of the process In be controlled. You Ihen defin" Ifte individual luks resulling from lills dividing procCSS by oclcnnining the functions and .tipulal1ng the interface 5ignal~ to Ihe process or 10 other msb. This brnkdown into individual I"".." can be don" in your program. In this way. Ihe <InICtll": of your pn~ corresponds to the di",slon of the automalion Ia.k.

A divided uocrpmgratn can be more easily configured. and cnn be programmed in Sl:Clion. (even by ."v"nll people in the case of very larac

n,

20.1 Pl"oiJ1lll1 Organization tions with wbkh you clln C~~tC "blo<:ks" (selfcontained program sections). Chapter 3.2. " l3Ioc k, '" dise u~scs the diffc~ nt kinds of blocks lind their uses . You will find a detailed description of the functions for calling and ending block!! in Chapter 18, "Rlock Functions". The blocks ~ceive the signal$ and data to be pl"OC(:~scd via the call interface ( the block parametcn). and forward the ~sulu over this !I-/Imc imerface. The optioll5 for passing panlmetCT9 are d escribed in detail in Clu>p1eT 19, "Illock Parameters". The following poinl~ of discussion can g ive only a rouih. very general view with the intention of g iving th e beginner :IOniC idea. on pmgram ~tructuring and on trRllslntin g his control task inlO reality. Advanced prognllnmen; nor_ mally have sufficient e>;~rien~ 10 organize a prolP"llm to suit the special con trollllSk a l hand.
A p I'OCH """"'lItcd PrDira m . t r uclure closely roll",,'s the muclUre of the plant 10 be controlled. The individual program se-clio ns COtTespond to the individual pans of Ihe plant o r o f the process to be controlled. Subo rd inate 10 thi s TOugh structure are Ihe scan ni ng of tbe limit sw itches and operator pancl ~ and Ihe co ntrol of the actuators and display device. (in different pans of the plant). Bit memo!), o r global data

20. 1.2 Progra m OrgnnlZlll o o


Program organizat ion det~-nnin~i whetber and in what ordcr the CPU will process Ihe blocks whkh you have generated. To organi= your prognun, you program block calls in tbe de.ired sequence in the sUPraQrdin~te blocks. You $hould cbo~ the order in wbich the bloch are c a Uw SO th at it milTOrs the process related Or funclion.re la ted division of the conn olled plant. Ne5llnk de plh The maximum depth applies for I priority class (fot the progrom in an orvanizalion block), and is CPU-dependent. On the CPU 314. for exam_ ple, the nesting d eplh is eig ht. that is. beginning with one organizat ion block (nesting depth I). you ca n add seven mOre bloc:ks in Ihe "horizonlal" ,li""'lio n (Ihis i . ca !l ~d nesli,tg). If more blocks are cal led . the CPU itleS to STOP with a " Block overflow" ClTOr. Do not forgel to include ~yslcm function block (SFR) calls aud system funclion (S FC) calls when calculating the IlC'Sling deplb. A data bl<xk ca ll. which is IIClWIlly only the nJ>C"ill.i or se lecting o f a dala area. has no effect on Ihe nesting deptb of blocks. nor is the nesting depth affected by callin g $Cveral bloc ks in success ion (linear block calls).
PU Cllee-r dliled p r Oil r anl Or i anlzAllon

"" ,
Intertocl<3 Ben control 1
Belt control 2
Oeta
acq u i s~ion

PI'OCfIU

Oata procnslng

Conveyor data
0.18 preparation

Communication

In o\"ianization block 08 I. you should caU the bloc"" in the main program in such a way as to roughly organize your PTOiT"'"- A program can ~ Ol"llanizcd on either a process-relatw Or funCl ion~late d ba.i .

CONTROl
Fill" .... 10 . 1
E~~mple

of PTOgnr.m Structuring

271

20 Main Program

are llsed for signal interchange between different parts of the p laJlt. I)rogram .tr uctul~ is based on the control function to be cxecuted. Init ially, this method of program strucroring docs not take the contL"Ollcd plant into account at all. The plant s(rueture firsl be~omes apparent in \h~ Sllbordinate bloch when the control function defined by the rough strucro", is divided nmher.
A
function-,..,I at~d

2{}.2 Scan Cycle Control


20.2.1 Proces. Im uge Updatinj!
The proce.s image is part ufmc CPU's intcrnal system memory (Chapter 1 1.6, "CPU Memory Areas'). It b~gins at 110 address 0 and end, at an upp~r limit slipulated by the CPU. On appropriately equipped CPUs. you can define this limit yourself. Nurm ally, all d igital modules lie in the process image addrc.s area, while all analog moollies have addresse, uuu;idc this mea. If the CPU has fre~ address allocation, you can lise !h~ configuration tabl~ to dircc! any mo d"le uvcr (be process image or ad~" it o utsidc the process imagc arCa . The proce." image ~omi'ts of the proces.inlllge input table (input, J) ~nd the pc<)C~s, imagc OU'PU\ table (outputs Q). After CP U re,tart and prior tu thc first execution ofOI:! I , the operating systcm transfers tbe sil,,"nal statcs of the process-image output table Ie) the output morluks and accepts the s ignal slates of the input modules into the proccssimagc input table. This is followed by execulion of OB 1 where n omlally the inputs ar<: combined with each othet and lh~ output. ar~ enutrolled. Fol lowing termination of OB I, a new cycl~ begins with the updating of tbe proce ss image (Figure 20.2).

In practice. a hybrid of these two concepts is nonnally u,ed. Figure 20. 1 sh",,,-s an example: A functional stmct"re is mirrored in the operat ing mode pTOb"am and in the data processing program which goes above and beyond the plant itself. Program sectioilll Feeding Conveyor I, F~~ding Conveyor 2. Pwcess and Discharging Conveyor are process-related .
exampk al'" shows the use of difTerent types of bloch. The main pTOgram is in OB I : it is in this progr~m (ha( (he b locb for the op erating moo~" the variou, pi<""C cs of plant ~q"ip meot, and for dala processing are called. These blocb are funelion blocks with an instance dmu block"" data SlOre. F.,~ding Coov~yor I and Feeding Conveyor 2 a.-c identically structured: FB 20, with DB 20 as ins' ancc dum block for Fec<.ling Conveyor 1 and with DB 21 as instance data. block tor Fe..ding Conv~yor 2. IS used tor con!rol. In 'he conveyor eonrrol pwgrdm. finlction FC 20 processe, th e interlocks; it scan:; inputs or memory bits a nd controls FB 20's local da!a. FWlction block FB 101 ~ontains the control progr....n for a ~onvcyor bclt, and i, called once for each belt. The call is a local jnstan~e"u (hal its local data are in instance data b lock DB 20 Thc same applies for the data acquis ition program in FB 29. The data processing program in FB 50, which USC" OR 50, proce>ses the data acquired ", ilh FR 29 (and otber blocks). which are located in globa l data block DB 60. fUllction FC 51 pre pares these data forlrans[er. Th~ lransfer is controlled by HI 51 (with DB 51 ), in whid, system blocks SFB ~. SFB 9 and SFB 62 arc called Here, too, the SFB, sav~ their instance data in "s"pllloTdinate" data hlod: DB 51 .
Th~

If an error occur,; during autommic Updating of the process image, e.g. bccau,~" mooule is no longer access ible. organi,,'diun bl(Jd OB l!5 "Program E,,~cution Errors" is called. IfOB 85 i. nO! anilable, thc CPU gocs to STar.
Subp r uc""
imag~s

With appropriately equipped CPU" you can d ivi de the process imagc into up to 30 subprocess images . You make this divi,iOIl during par."mcl~rization of the signal modllies by def,nin g [h~ subprocess image via which the modul~ i, to be addressed whe n you ""igo nddresse,. You can scparm e the division accoTdmg to process-image input table and proces;;-image OUlpul table. All module s that you do nO! assib'Il tu one of lhe subpro~c," image s I to 30 are stored in subprocess image 0, '" hich i, also called the OB I pro-

20.2 Scan Cycle Control

Order of execulic", 10r CPUa up to stllrt of deU"al1l'011998 Start current cyct ic execution Cur ....nt c c ia time 08 1 Start nexl cycl ic e~ecul i on

...

...

'"
Start currMI cyclic execution

Ma in ;>rogram 08 ,

...

"0

'"
Start next eyel ic execu~on

Main prog ram 08 1

...

?
.

Order of execution for CPU, from stllrt of delive ry 10/1998

Current cycl e time 08 1

PIO

I PII

...
Main progra m 08 1

...

P IO

I PII

Ma in program 08 1

... ...

Order of exaculfon for Inte rrupt organization blocks with subprocess.lmege Start internJpt handling Runtim e of the interru End Interrupt hand ling anlzetlon blcck

..
inpu' 'aM.

,,,

m
NO
SPIt"
Sf'lU"

proc<Mr,"a~e

or ,,,PP""C'J,.i,,,,,1P' 0

...
SPtln Interrupt organ izat ion block

pm'mage ""'P<" ",bl. or ,"bp""'." . (ma1<" a Subp""""'.im"!(e" ihpullabl. Sub nxe' i"",K' n ",,'pur ,"ble

...

SP IOn

Figure 20.2 updating Ille Proc".. Image

cess image (OB I_PI) . This subproce .. image 0 is updatcd a"tomalicaUy by the operating sy, tern of the CPU as pan o f cyclic execution . You can al>o program the CPU sllch that the auto mmic updating is switched off. With appropriately eq"ipped CPUs, you can also assign the subprocess images to the inter nlpt org anization blocks so that they are auto matically updated when th ese O Rs are callee!. The system functions SFC 26 UPDAT_PI and SFC 21 UPDAT _PO are ava ilabl e for updating the subprocess images by the uScr program. In th e o rganization blocks for sync hronons cycle interrupt, you usc the sy<lem functions SFC 126 SYNC_PI and SFC 127 SYNC_PO (Chap ter 21 .8.2, "lsochrone Upd ating Of Process Image") .

SFC 26 UPDA"f_PI SFC 21 UPDAT_PO The system func tion SfC 26 UPDAT_Pl updates a subprocess image of the inputs , the system funct ion SFC 27 UPDAT_PO updates a subpro~css image of the o utp uts. Table 20.1 shows the parameters of these SFCs. You can also update subprocess image 0 wilh these SFes. You can carry out updating of individual subprocess images by call ing these SFCs ," any time and at any loc ation. For example, you can define a subp rocess image for a priority cl ass (a program execution level) and you can then cauS e this subprocess image to be updated at the Slan and al the end of the relevant organ iza tion hlock when 'his priori ty clas< is processed. Up<lating o f a process image can be interrupted by calling a higher priority class . If an elTor

27.1

20 Main Program <>ccu r,; during up<iatitlg of a proc ~", image. c ,g. i:>ccau,e ~ module c~n no longer b e ac~~,>ed. this error is reponed yia th e flu"'tion value of The src. The parameTerized minimum cycle dumlion and th e s~an ~yd~ monitming tim~ aTe also d i, pbycd . The cycle { ; m~ for the la't cyde and the mi nimum and max imum cycl e time since (h~ PLC was la,t Slane<! up can also be read in T e h t~mporary local data in the .Iart informarion ofOB 1.

ZU.2.2 Scan Cyc le Monitorin!: Time I'rogram scanning in orgatlization block O B I i ~ monitor~d by the so-calle d "scan cycle mOIliTor" or "scan cycle w"l~hdog:". The default value for The scan cycle mon itoring time i, I SO ms . You can change \hi s valu~ in the rang~ from 1 ms 10 6 , by parameterizing the CPU ac~ord ingly.

StT.tJ R f:_TR TGR


Resta r ting rh e sca n cycle m Olli toring time An SFC 4 3 RE_ TR1GR SYSTem fundion call restarts the Scan cycle monitoring lime; the rimer "" tart, with The new value ,ct via C PU p~mrn;:tcriz~tion. SFC 43 has n o parame ters. Operating <y.te m run Umes The >can cycle Time al~o includ~s the operatin g sy slem nrn lime" Th~"e are eomp<Js~d of the following:
(>

if th e mai n program takes IOllger to scan than \bc specified scan ~yde monitoring time. {he CPU calls OS 80 ("Timing error"). If OB 80 has no\ lx:cn programmcd, the CPU g<><s 10 STOP.
The sc:!n cyc le monitoring lime indudes the full scan Time for OB 1. Tt also inc! ",\es the scan times for high~r priority classes which imenupT the m~ill program (in the eun-em cycle). Communication p roce"e, ~arricd oUt by the opcr~t ing 'ystem. su~h as GO communication o r PG acces s to the CPU (block 'talU"), also increa,e the runtim~ of the main program. The increa"~ can be rcdueed ill part b y the way you paramcteri~ the CPU ("Cyclic load from commllni cs tiou " on the "Cycle1Clock m~ m""Y bits" Tab)

Sy'tcm control of ~y~lic cycle- ). fi~ed vaJLLe

s~"nning

("no_load

(>

UpdaTing o f the proces, image; depend~'Jl t OIl (h~ number o f byres to])., updatcd Updal ing of the tim~'fS; dc!)<'ndent on the number of Ti mers To be updaTed Communications load

(>

>

Cyd .. statistics If you have aD online connection from" programming dev ic e to an operating CPU. >d~e( PLC ---c> JI,10DIILE lN FORMATIO~ {o call IIp a d ia log box thm contain, " ~' nal tabs . The "Cycle Time" tab ,how , the current cycle T im~. as well as the >ilioncsT and longest cycl~ Time .

Conunurncatiolls functiolls for the CPU include tbe tran, f~.,- of ",cr progmm blocks or daTa c x ~ h an g e betwee n CPU modlllc s u s ing system fu nCTions , The T ime the CPU is to use for Tbesc funCTions can be limi1ed by paramelen z in g the CPU. A ll \alueS a t operating 'yS{~ 'IIl runllme pTOperties ofIhe re levant CPU.
"Ie

T:tblc 20 t PART
RCT
V~

Para mct~ .,.

[OT the SFC, rOT ?roc" l.J.na~e Upd:>,ing


De.:!aration
D.", TYl><
C"tlte~"",

h"'-TJ'tSt.cr_'<""""

5)FC

FLADDR

" " " n n " I

INPUT

BYTE
<NT WOR!)

RETURN OUTPUT

n . ""Tiplion ~u mber of the ,ubp",)..-"" image (0 to 15) Eaur infOTTTllitiun On an ac,ess error: Tbe adc!ress of tho firS t
hyte to ca",. the e<ror

20.2 Scan Cycle Control

20.2.3 ).flnlruum Scan Cyd., Time, Back_

ground Scanning
\V,th a ppropriate ly equ ipped CP Lls . yo,", may s pecify a minimum scan cyd e time _ Tf lhe main program (inc!",jing interrupts) lak es less time. the CPU waits unt il the spec itied mi nimum scan cycle tirn~ has elapsed h efore be ginning the next cycle by recalling OS I . dcfaOlIt va luc fot th~ minimum _,can cycle time is 0 ms, th at is to ~ay, th~ function is disabled, You can set a m in imum S~an cycle tim~ of fro m I ms to 6 s in "Cy~lci Cl"",k m~mory bits" tah whe n you parame teri z e the CP U . Background . canuin g OR 90 In the int~rva! between the actual e nd o f the cycle and expiration o f the minimum cycle time, the CP U executes organ ization b loc k DB 90 "Backgro und scanning" (Figure 20 .3) _ on 90 is cxttuted " in ,li~c ," , \Vben the ope rating system c alls OR I , cxc~U1ionof OB 90 i, interrupted : it is Then resum ed at the poilll of inlerruption when OB I has lerrnin" ted , OB 90 can be int<-rrupted after each statemenl, any sy ,\~m
Th~

block ca lled in OR 90 , however, is first scanned in it s entirety. The length of a " slice" depends on the ~urrenT scan cycle ti me o f OR I. The closer O B I 's scan time is to the m inimum sc an cycle T ime . the less tim<- remains fo r e"eCUTing OB ~o , The program scan time is not monitored in OB 90. O B 90 is seanned only in RUN modc. It c an be interrupted b y interrupt and error event" just li k e OB L The stan i"fonn at;on ;n the temporary local dam (Byte I) a lso tell. whi~h even ts call,e OB 90 to e"ecute from the beginning:
[>

8 #1 6# 91 A fter a Cl'U restart:


B# 16#92 After a h lock procc,",cd in OB 9 0 wa" deleted or re placed: B #1 6#93 After ( re)loading ofOB 90 in RU"l mode :

I>

"
[>

B#1 6#9 5
After Ihe program in OB 90 "'a" scanned and a n e w b,,~kground ~yd e begins.

Orde r of execution for CPUs up to start of d ..!ivery 1011998


Start current cyc lic exe cution

,
Start next

"i',

Curren t cycle time OB 1

Contin uation of execution in 08 90

cycl ic execution

'"

Main prO>jram OB 1

... ...

"0

Backg round OS 90

Minimum sc"n cycl. tim ..

'"
,'.'.

0"'

Order of """cution fo r CPUs from start of de livery 1011998


Start current cyclic execution

,
Start next cyclic execution

.:,;..,:;,';:';::,:

Current c cletlme OB 1

Contin ua tion of execution in OB 90

PIO

! PH

Ma in program 08 1

... ...

Ba ckground OB 90 Min Imu m scan cycle tIme

P IO

I Pit

08 1

_ igure ! O,3 M in imu m Cycle Du"'ti"n and Baciq;round Sconning F

275

20 Main Program wg of ltllerrupt<, th e fu nction, cHrried out by the operating system, such a, updating ti rn ~rs. controlling the i\ 1PI intaf,,~~ and updating the p=e<. image<)

20.2.4 Response TIme


Ifthe user program in 013 I work:; with signa l states of the process "nsg~<, thi, result. in a response time which i" ,kpend<.'l1t on \he program cxeclllioll limc (. can cyck tim e). Th e response time lies oc tween one and t\VO scan cycles , "" Ih,' f()ilowing exrunple explains, When a limit switch is activated, Cor ins\al1 ce, il changes its ,jgn~ 1 <late from "0" to " I". The programmable controller detects this chanl;c duri,,!> {he subsequen t updating o rt hc process unage . and scb tbe inputs allocated to the limit switch to "\" . The progrrun evaluates 1bi:; change by resetting an output, for example, in Oro"T 10 switch off the co=sponding motor. The new signal "t,,{~ o[mc OUtpUI mal ,,-as r<:set is trmllif~'TTed ~l the end of 1he program ,can; only lhC11 is the corrcspondinl; bit resel 011 the ,hgital output mn<.luk. III H bc,\-c~se ,iIDation., me prOl:ess imagc " updat,,,l immediately following the cbange in thc limit switch', . igl1,,1 (F igure 20A). Tt would thcn take only onc cycle for the ~Ievan! output to respond. In the worst-case simmion., updatin g of the process image was JUSt completed whell the limit switch signal changed. Tt would then be ncccs,ary to wait approximately OIle cyclc for the pro!lflill1lllabk " untroller to d"tect the <ignal chanl;~ and SCI th e input. A fler yet another cycle, tbe program can respond. When so con"i dered., the u ,cr progr3m', c.,~ec ,, tiulJ lime contain" :on pT<J,edl.l"" in one program cycle (including. for instance. the servic -

we

The n:,pon,c time 1-0 a change in an inpm signal can thu, be hem'een o~e and two cycles . Added to the respo".e ti me ar<: the delays fo r the input modules, 1he ,w itch ing times OfCOn!3CWN, and
.0011 .

Tn wme instances. you can reduce the re'pon,~ lime , by addre>Sllg the liO, dire~tl)' or calling program sections on an event-driven basis (proces s imerrul>l) You C3n 3chieve uniform response lim~S or equal time imen'als for the prnces, control if a program c<Jmp<Ju~nt is always process~d a' the ,aJ11C time interval, c.g . .., ~yclic inkrrupl rrogram, Program processing i,ochronous w ith t he pn,,;cs,ing ~ydc <Jf a PROFIBUS DP mB.<1er sy,tcm als() rroduce~ calculable r~.po"se time, (Charter 21.8. "Synchronom Cycle II11"TrupIS"),

20.2.,5 Start Tnfor n'at;on


The CP U ', operatir::g system fo!Wards otaT! infonna,ion t<J <Jrganiz..,tion bl<.>ek OB 1, as it ,joe, to c,'cry organization block, in the first 20 byt ~s of tempormy local data. You C3n I;~ncra te the declaration for the stall infom1at ioD your, elf <Jr you Can ,IS" informmion from Swndard Library undC1' O"g'mi~"tio" Blocks.

Sensor signal chllnge with immed iato t f~nsf ~r to process-Image

... O utput sign" t Mango

Response time _ one eye t.

Ipl, o

'"

User progra m Sensor sijon,,1 chang~ without transf" , to prQc~~s~mag o

---

-- -

I ,>0

'"
Transfar to proce ss-tmage

User P"'llram O UlpU!

. --

. --

I PIO
si gn~ t chan~e

'"

Ruponu 11m.. _ Iwo cyclu

20.2 Sc.n Cycle Conlrol

Tallie 20.1 Sum Information for tile OR


.j

!l

~~

1:I=16i!'03 B# 160f()4 -

En!)' OIMT cy<:1e

ht cyde afler cold

Table 20.2 shows this stan in fon"at; on for the OBI , the default symbolic designa tion. and the dala types. You can change the d~"S igoalioD at any time Illld choose names mo: acceptable to you. Evo:n iryou don't u.<e the stan informanon, )'l.lu mU$I reserve the finn 20 bytes of tcmporery Incal data for 'h is ptIrpose (for InSIance in the form Of a 20--byte IIrray).
In SI MAl"lC 57, all CVet" mc.~sages have" fiXed ,tNcture whi~h is spedficd by the eVent clas~. The start information r"r OEl I , for instance. reports event [litl 6# II a$ a standard OB call . from tbe contents ofthe nexI b}1e you can tell ..... helher the main prognlm is in the first cycle after power-up and is therefore calling. for instance. initialization routines in the ~ydie prolt'"R"'. The priority and 08 numher of the main progmm are fixed. \Vith three INT va lues. the stan infonnotion provides inf"rmation un the cycle time orthe last scan cycle and on the minimum and maximum cycle timC!; since the]a" powerup. The llUl ~"lIlue . in DATEj\l'\D_TIME formill. indicates who:n !he prionty control program re<;ci~"Cd the event for callmg o n I.

0lJj:ani7..ation block because thut information consists of temporary local data. If you require the stan infonnation in blocks which lie o n deeper levels. call sy"em function S FC RD_ ST?-."FO at the rel~t localion in Ihe program . S f C Ii RD.SL'I FO Rudlnlol (Jut start Informatlnn Syste m fun~tion SFC 6 Rn.S INFO makes th e ~ta" information on (he cu~nt organization block (that is, the 08 at the top ufthc cal! lIce) and on the stan-up 013 lUI executed available to you eV"" al a deeper call1e,"el (T'ablc 20.3). Output parameter TOP.51 containi 1M first 12 b>1e;; of stan information on the cu rrent OB, OUtpUt parnmeter START. UP. S I tbe first 12 bytei of stan information nn the llUl Start -up 013 executed. There is no time ~t .. mp in either case. SFC 6 RD. SlI\rO can nnt on ly be called at any location in the main program but ;n every prin,ity class. even in an errOr organization bl ock or in the Start_up roUlin~ . If the 5 FC is called in ~n intL'lTUpl organization block, for example, TOP.Sl contains the start information of the interrupt OB. In the ca~ of .. call at ",start, TOP. 51 and START.UP_ SI have the same contents.

Nnle thai direct ",ading of the start in fOTmanon for an organization block is polS;ble only in that

20 Main Program Table 20.3 Paramctcni for SFC 6 RD SFC

S l~'FO

Parameter Name

RET VAL TOP_S l START UP ,EV_CLASS ,EV_NUM ,PRIORJTY ,NU>.1 _ TYP2 J .TY PI .Zl l _ li2 3

Decl ....ation RETURN OUTPUT


OUTPUT

D.ta Type
INT

Con!eDts. Dc,;criptioD F.:mr infonnatinn Slart information for the CurrOn! DB ("'ilh the same strucNre os START UP ") S"'rt information for tho last OB started, E"ent ID and ''''~ nt clao< Even' Dumo.r E~ocution priority (number of tho <"""mion leve l) OB number !D o[sllw1emem.ry information 2_3 lD o[sllpplemem.ry infurmation I Supplementary information I Suppl~m.ntary information 2

STRUCT
STRUCT BYTE

"

om
" '

m,

,m
WORD DWORD

BYTE

20.3 Program Functions


In addition to pammeterizing the CPU with the Hardware Conliguration, y(}U can al50 select a number of program functions dynamicaUy at runtime via the integrated system functions,
2[1.3 .1 Time of day

Sett ing a nd readin g the t ime of day Calling the SFC 0 SET_ClK or the SFC 100 SET_ClKS us ing MODE = B#I6#OI or B#16I>03 set the clock to the va lue defined by the PDT parameter_ SFC 0 SET_ClK set. th~ win ter time for CPUs with summer/winter time idemification. With the 5FC 100 SET_Cl KS, you can use the SUMMER Ilarameter 1 define 0 whether the time is the winter time (with " 0") or the summer time (with " I "). The current lime is r~ad by SFC I READ_CLK and output in the CDT parameter. The time has the format DATE_AND_TLVlE when sellin g and reading, i.e , therefore contains the date an d lime, Modul. time. toca l time The time present On the CPU is the module time. This is decisive for all timcd processes which control the CPU, such as run_li me mctcrs. suming of time_of_day interrupts or cntering of lime stamps in the diagnosli ~s buffer and OB start information, You Can set and read the module time using the system functions for the CPU clock. CQrrespondingly desi gned CPUs addilionally save a "time Slatus. This contains a correclion value which reslll" in the local time wben added to the module time. The correction value is set in interval s of 30 minutes, and can also be negative (CORR pammetcr of SFC 100 5 ET_ CLKS) , The loca l tim .. can be used to display time zone,.

Each SIMATIC CPU has a clock which you can sct and scan u.ing STEP 7 or syst~m functions _ The timc of day is rcpresented in the u'~r program in the format DAfE_At'-' D_T1:vIE. consisting of the dat~ . time and day of week. Newer CPUs witb firmware version 3 and higher allio havc thc time status_ You can then additional ly set a di fference from a time zone a, ",'ell as .ummer/winter time identification_ The following system functions Can be used to access the CP U clock:
t>

SFC 0 SET_ClK Set datc and time SFC I READ_CLK Read datc and time SFC 48 SNC RTCB Synchronize CPU clocks SfC 100 SET_CL KS Set time of day, date and time status

t>

"
t>

Vou will find a list of 'ystem function parame_ ters in Table 20 ,4.

20.3 f'Togram

~Unclion.

Tabl.20.4 Si'C Parameter:. fm

tb~

CPU Clock Dan'l)'p


Conte~l6. D_r;l>lio~

SFC

Parmnet:::r N_c

Declamtion

" ,
" W"

mT
m
V~

m,UT
RETURN REnrRN OUTPUT RETURN INPUT

DT
mY

Date a"d time ("ew)


Error lnfo!"Illation

ROT VAC

TNT

CDT
RET V~ MODE

Of
INT

Error information Date and lime (curre nt) Error informa1ion


Operatin~ rnoo~

BYTE

1l# 16i'03: Set time and lime .tarns

B" 16;;02 Only ,et time ""'n'

fI# 1Mit)): Only set time

POT
CORR

iNPUI L"IPUT INPUT I!-.PUT

OT
L"T
llOOI.

S UMMt:1I. ANN_

ilOOL

RET

V~

RETURN

'NT

Dc tim'd t;mo Differe nc e f,om ba<;e time in O.5-hour inter "ah from -24 to +26 Summerlwint.r time id.nt;fjc~tio" CI" - s um mer tirn~) Announcement of time ,witchover: a " 1" indic"'e' that" ,witch is made fmm mmmcr time to w lnter time or vice vcr,~ the ne'~' time 'nat th~ hour change" Error informatiOll

Time s tat us The time status is set whell parameterizing the CPU with STEP 7 or w ith the SFC 100 SET_ eLKS . The time of day and the time statU.'< ean be read using the SI'C 51 RDSYSST vi a the system stams list (SSL_ID - W# i 6#O 132 with IND EX W# I6#OOO8). The slaWs v<mable includes:
p.

Loadable ,tandard blocks help you to hand le the ""mmer/winter time <witching of the local time in th~ user program, in particular the starting "fl ime-of-day inK"fl"ur>ts depending on Ihe local time (_ee further below IIndeT, "u>adable time-of-day b locks").

Time synchronization In an automation network wi th sev<'-"ral STM"ATTC stations exchanging dat<I with one anot..'>.eron subners, it is possible to synchronize the clock.<; of ~11 CPUs. You parameterize the n cloc k of one CPU as the "Masterciock , and ~et Ihe interval at which the synchroniation is to be carried out. You parameteriz e the blocks to be synchronized as "S lave c1<><.:ks". The synehroni'lalion can be carri ed out within an S7 stmion over the conmlUIlication. bus (ba ckplane bus) or between "Iation~ over the MPI bus . This is carried out at th~ parameteri ~~,<! interval aUlmnatically wh~"Il (he master e lock is set for th~ tlrst tim~. Jfyou set a clock with the SFC 0 SET CLK or SFC 100 S ET_ CLKS, al l other clocks in the subnetwork are automat ically synchronized to Ihis value.

The correction value (bits 2 to 6) in the 30- minute intcf'lal


Tb~

p.
to>

sign of the cotre<:tion

v~juc

(bit 7)

The ,ummer/ winter time identitication (bit 14) The


allll ou nc~ ment

[>-

hour (bit

I ~)

T he ."mmerlwinter time identijjco.lion shows whether the local tim~ calcu lated from Ihe module time and the correction value is the ,tllnmer time (with " j n) or the winter time (w ith 'D') . If Ihe announcement hOllY bit has th~ stams "j", the switebovcr from sununcr time to winter time i" carried out althe next change in hour. Using the time statu, infOrlnation, a local t ime can be generated from lhe module time ill ordeT to cOnl",1 timed pn:><:esses in the u~er program.

==

20 Main Program By calling the SFC 48 SNC_ RTCB in the mas clock, you can synchronize all slave b locks independent of the automatic interval. If the master clock does not have II timcof-day status, the slave docks are synchronize" with the winter time. The correction factor is zero, the local time then corresponds to the mod ule time. If the master clock works with II time_of day status, the ~omplet e time status is transmined in addition to the time. Therefore the same local time (the same time zone) exists On all CPU, in the lime network.
Set time ,.. rn g STEP 7

0-

lCT

I'B 61 SET- SW- S Switch over s ummer/winter time with time status
UDT 60 WS RULES Rules for switching over summer/winter time (e.g . time for switching over)

0-

20.3,2 Read System Clock


A CPU's system clock start, runn ing On power-

up. The system clock keeps running a s long as the CPU is executing the restart routine or is in RUN mode. When the CPU goes to STOP or HOLD. the current system time is "frozen'".

If you initiate a hOI reSlan on an S7_400 CPU,


When sett ing the CPU parameters, you Can set the synchroni?,.ation mode (ma'ter, slave or non~) ,md the synchron ization imerval in the attribUies window on the "Diagnosticslclock" tab). The correction value set hue is used to set the clock accuracy. You can set the time and tbe time StatuS using STEP 7 if the programming device is connected online to II CP U. Sekct PLC ..... DlAGJ','Qsncs/ CUSTOMtZE ..... SET TIME OF [)A Y. III the enhanced d ialog, you can set the local time as a differencc from the module time, and defIne the mmmeriwinter time. The time status is shown in the <'Status" box. Loudable timc--of-day blocks The program Miscdloncou. Bloc", in the Sla". <
dard Library contains loadable hlocks for han-

the system clock stans running again using the saved value as its starting time. Cold restart or wam, restart reset the system time.
The sy'tem time has data format TIME,
whe~by

it can asswne on ly positive values:

TIME#Oms to TI!I.1E#24d2 0h31m23sM 7ms. In th e evcnt of an overflow, the clock stans again at 0. Newer CPU. update the 'yslcm clock every millisecond, older S7_JOOCI' Us every 10 milliseconds . SFC 64 TTl\IE_TCK Read srste m time You can read thc current system time with system function SFC 64 TIME_ TCK. The RET_ VAL parameter contains the system time in the TIME data fomlat . You can usc the system dock, for example, to read out the current CPU runtime or, by computing the difference, to calculate the time hcme .. n two SFC 64 calls . Th~ diffe~n ee ~tween m'o valu es in TIM E fonnat is computed us ing D INT subtract ion. 20.3.3 Run-Time "Ieter
A run -time meter in a CPU counts the hours.

dling summ<..-r/w inter time s wi t~hing and the local time in the user program
b-

FC60LOC_ TTME Determine local time FC 61 BT_ LT Convert module time into local time FC62LT_BT Convert local time into moduk time FC 63 S LTTNT Sett ime-of-day interrupt to local time FB 60 SET_SW Switch over summer/winter time

b-

b-

(>

You csn u,e the run_time meter for such tasks as detenll ining the CPU runtime or sscet1aining the runtime of d.-vices connected to thai CP U. The value on tbe run-time rueter is also retained following e oold restan. failure of the backup voltage. and following a memory reset.

0-

'"

20 .3 Program Functions Table 20.5 Parameters uflhe SFC. for the Run_Time I>letet

.,

'"

,.
"
The range of values and the number ofron-timo me= per CPU dcpend on the CPU, The rang e is 16 b its (2 15_ I hours) or 32 bils (2 31_ 1 hours). When the CPU is at STOP or HOLD, the run-1ime meter also .10pS running; wh~n Ihe CPU is rcstallcd. the run-time m eter must be restarted When a run-time meter reaehe, the maximum time d "ration , it StOp, and reports an overflow. A run-time met ~r can b<: ,Cl to a ne w value or reset to zew only via an SFC call , Thc fol lowio g system functions are a vailab le to control a run-time meter;
D-

can be initialized us ing a ~onstant or a variable (as can all input parameters of el ementary data type). The PV parameter (data type fNT) is u,ed 10 set the m n-lim e m eter to an initial va lue. SFC 3's-Sparamctcr starts (with ~ ignal siaic "I"') Or stop, (with sif,,'nal _.tate "0") Ihe selected run-time meter. CQ indicates whether the run-tim e meter was ruoning (signa l stale .. I ") or stopped (signal State "0'') when scanned, The CV parameter record, the hours in INT format. By aSSigning Ihe MOD 6 parameterofS FC t u t. you can control a 32- bit run_time m eter as fol lows : B#I6IiOO B# I6#01
B 1t 16 ~02

SFC 2 SET_RTM Sel I 6-bit run -time meter SFC 3 CTRL_ RTM Start or stop I 6-bit run-t ime meter SFC 4 R.EAD RTM Read 16_bit run- time meter SFC 101 RTM Adjust 32-bit run- time meter

Read current meter value Start at last meter value Stop meter Set to value specified in I'V Set and stall at value speci fi ed

D-

D-

B#1 6#04 B#I6#05


Sol- l6#06

ev
PV

'"

Table 20.5 shows the parameter for these system functio!l.'l . The NR parameter stan ds for the number of the run-time meter, a nd has the data type BYTE. It

Set and Slop at va lue "pe<:ified in

You can al so u'e the SFCs for a 16_bitrun_time m eter to control a 32_bi t run_time meter. The

281

20 Main I>rogram Th e maximwn waiting time is 32767 I's; the minimum waiting time ,urresponds to the exe,ution time or the system function, which is CPU_spec ific. SFC 4 7 can be interrupted by higher_pr ior ity e\'~'DI.S. On an S7-3OO, mis increase.> the waiti ng time by the "" an time ofthc higher-priority interrupt routine. The system function SF C 46 ST P tenniruttes the prollram ,",an, and the CPU gocs to STOP. S'FC 46 STP has no parameters.

laner then rcsronds ns with a l ,,-b it range uf vnlu es. 20 .3.4 C omprc .. inK C P U
M~moQ'

Multiple del etion and reloa ding of bl""k:;, which otlcn ""cur during on line hlod:. modification, can resu l' in gaps in thc C PU's work m "",,,ry a nd in the RAJv1 load m emory which decrea se the amuunt of USllblc space in mem _ "'y When yuu call the " C ompress" ti.lll ction, y ou start a CPU program which tills these gaps by pusbing the blocks togethcr. Yuu can initiate the "Com pre,," f unction via a prOb 'TammiJ1 g dev ice c OIlllect cd tu the CPU or by , aUing ,yste rn fu nction SF C 25 C O :-' fPRES S. n , e p aramete r< for SrC 25 are lisu:d in Table 20.6. The compression p roced ure is d llitributed over several program cycles The SFC reHlI"f" RU SY - "I" to ind icate that it i< still in progress, and DONE - "I" to indicate th at it has cumpleted the c umprc>sion uperation . The SF"C call1lot comprcss whcn an ex ternally initiated cu mpression i< in progres., when the "Ddetc B lock" ti.mction is active, or when PG func tio n s ore accessing the block to be shifted (for instan ce thc I:Iloek Status function). Nute th m block:; of a particular CPU_specific maximWll lenglh cannot be compressed. so that gaps would sti ll remain in CPU memot),. Only th c Comp rc.s function initiatcd v ia thc PG w hil e the C PU is at STOP closes all gaps.

20.3.6 M uitip r oc csslll: " 'lo de The 57 -400 en ables multiproccssing. As many as four appropriate ly des igned C PU s e"n be operated in onc rack on th~ ,ume P bus and K bus. An S7_4{)() station is automatically in multipro ce s> or mode it you arrange more than one CPU in the ~entml rack in the Hardware Cunfig uration . The slot.> ~r e arbitrary; the C P Us arc d is tinguished by a Dumber a"ib'Dcd uut"matically in ascend ing order when the CPU, are plugged in. You can also assign this number your>d f un lhe "Multieomput;ns" tab. Thc configuratiun ,l,l;i fur all the CPUs must he loaded into th~ PLC, even when you make chang~s to only one CPU .

After assi gn ing parameters 10 tbe CPU,> you


must assign each modul~ i1l the station to " CPU. This is don e by parameterizing the moduk in 'he "Addrcss~," tab under CPU Allocation" (Figure 20 .5). At th ~ sam, time Ihal y<>u assign tbe T nodule's address area, you also assign the module's interrupts to this CPU. With VTEw ---> FlL TER ---> CPU No. X - .\10D ULES, you can empha size tbe module, ~s>igned to a CPU in the config uTation tables.

20.3 .S '\Vait in l: a mI St opp in g The syste m fun ~'1ion St C 47 WAlT hait, the program sca n fur a specified period of time SfC 47 WALT has input parameter WT of data type tNT in whi ch you c an spec ify the wailing timc in mi croseconds !fl').

Tab le 20.6 Panuru:tcr. for SFC 2S COl\-lPRLSS

20.3 Program Functions

P....,.,,"~ ,

lJtth><IJI " .v tnt~"upI

III00S ' 1

'I

p- .E"" pttIC . . . " , , !:!"---

1 I 2

Figure

20.~

Module Assignment> in Mul,iproces>or Mode

The CPU s in a multiprocessing ne1,,'ork all have the sam e operating mode. This meanS
t>

The y m'-'5t al l be same restan mode:

para 'neteri ~e d

wi th th e

ey of the time acqu isition is C P lJ-dependen! and the times arc ~pec ifi ~-J in microse~onds. If there is no value pending for a requested time, - I (O Wit I6#FF FF FFFFj is returned , Principle oftime mea.urement In the operatinli\ system of Ihe CPU, a timer runs wilh a relative time in m icroseconds from o to 2 31 _ 1. A t th e rran,ition from STOP to RUN . the timer is started. runs 10 the upper 1im_ it. and then start s a gain from zero. The OB stan even!, the beginning and end of OB execution. an d the intclTUption" caused hy h ighe r-priority OBs are caprnred in thc operating system. T he data of th e last compl eted OB execution that was current allhe time of calling the SFC 78 is stored SFC call outside the OB to be measured applying the SfC. a d ist inction is made b ctween a call in Ihe program of the requested OB aud one o utside the requested OR. E",am pie: The SFC 78 is called in the OB I and is assigned a value " f 30 in the para meter O B _ NR. The la:;t captured times for OB 30 are then read, Specifi cation of the synchronous error OB with the numbers 121 and 122 is not penn is s ible because these be long to the priority c lass ofthe error-c ausing OBs and tbus to their pr<>gmm
Wh~n F i gur~ 20,6 shows some examp les o f calling SFC 78 outs ide th e OB to be mc" sur~d, The ini -

t>

They all go to RUN simultaneous ly;

"" They ~ll go to HOLD when you debug in single-,t\.l' mode in "ne of the CPUs; "" They all go to STOP as soon as "ne of Ihe CP Us goes to STOP. When "nC rac k in the slation fails, organization block OB 86 is called in each C PU , The user program s in thcse CPUs execute indepcmkm ly of one another; they are not synchronized. An SFC 35 MP _ALM call start, organ ization block OB 60 "Mu ltiproce ssor interrupt" ' in all CPUs simultaneous ly (sec Chapt~,,- 21 ,1 . "M ul tiprocessor Imcrntpt"j , 20.3.7 Delermlnlng the OH I'rfIj;(ram Runtime The system function SFC 78 OB_RT determine, the runtime of in dividual organization blocks over different time periods. This enables you 1 detennine the time load (utilization) of 0 the u, er program. The operating sy st em of a CPU designed for this purposc log, Ihe run! ime~ of the indiv idual organi~alion blOCks and m ak es them available for readi ng vi a Ihe SFC 78 OI'_ RT. The acel.lrS-

20 Main Program

Parameters oflhc S l-"C 78 INPUT


[NT

tim.", .'" to be

OUTPUT

nTKT

\ial values after a ST O P-RUN transition (c xarnple(Dl ,

a~ - 1

prionty cla"es

a~ nOI

includ ed in LAST_RT

(@).

L A ST RT indic ates the nl!)lime in m;""" ec onds o f the laSI co mr leled 0 13 e"ecution (ex am pl es (%) 10 @). The -'n et" runt imes arc output. lnterrur t tim es cause d by OBs wilh higher

LA ST ET indicales the tim e p"riod in m inoseconds between the stan request and (he en d of process ing for Ihe last "omplct"d ""cculion o f

Sl OP

IRUN .

S FC7 6 calt outsid e the organ(2alion block to be mM$O'ed

Interrupt"'n by 06 01 highe, p riority

l tD

(j)

O'n processing O'n s tart ' '''luest


SFC780a ii

o
!

D
I I

O
I I I I

(OS_NOa xx)

I I
' ....

II I I I II I I I

II
I

o
I I

I II I

v. tu in ,o.. SfC 71

p" . . m.

Fig",,",, 211.6

Ca llin ~

SFC 78 outside tho orson ;n,;on h lock 10 be measured

'"

ZO.3 I'roaram func.ion$ Ihe 013 10 be measured (e:ump!CS@IO@). In lem.tpl limes cause<! hy higher prinrity cla"e, are included m LAST_ET (@). CUR_T indicate , the rel ative lime in microsec onds (~Wtus oflhe counter in the operating sy, tem) of the start I"filucst of the OB. After initial ization Ct JR T {(D) conLain~ -I. On comple.tion of OB eunnion, CUR T i~ let to zero . Since SfC 78 i. can.-d out.ide the OB in these exampk~ ;1 cons.-quently OUtputS zero at thi. ()artlmelcr. CUR_RT indicates the effective execution time of the O R W1ti l calling "f SFC 7g in microsc~ onds. After initialization CUR_RT (CD) con taiDs 1. Anercomplelion ofOa execulion, the vallie in CUR_RT is IrllmfermJ to LAST_RT and CUR_ RT i. set to "",ro. Siru."l.' the SFC call laJ.:c~ place outside th" oa in these exampk-s, the value i. alway. zeTO. CU R_fiT indicates the time period from the OB sian request to calling of SFC 78 in mieroscc onds. After ~ompletion of OB c~cc"ti on, the value in CUR ET is transfen-cd to LAST ET and CCR_RT i:, <et to ~ero. Since the SFC-call
tak~s place out,ide the OB in tht'SC the value is alwa)" zero e~amples,

NEXT_RT indicates the time from the next OR .tan !\:qllC>1 10 callin!> of the SF<: in mkro.",, o~ds if fllrtbcr. IInproceued stnrt reqllcst& are fK'nd~. In the ~~sc of the eUrRmly supplied CPU" NEXT_RT i, not ealcll[ared IUId the val ue is al""'~5 -I. S FC u llin th e pr ognm nr th e 08 10 be
mCll~ ured

S.F C 7~ can al,o he call ed in the program of the 01'1 t() be measured. The parameter O B_NR i. then initialized with ~t'To and the ()arametcr RfT_VAL returns the c~nt OB number - in Ihe C~ of error fr..., e~eculion . The limes for the O D in which SFC 78 is ea ll .-d an; read. When calJ..iDg in one of the . ~nchrooous e-rmr 0135 witb the numbers 121 and 122, this is the data of the OR causing the error. fijjul"C 20.7 shows some examples of calling SfC 78 in the program of the OB 10 be mea gured. This elln be dire<;tly in the

on program
De

In......,p1lon ~ OB of high prio rity


o,~

~E'
i ,

SFC78 eellinlide t!le organization bInc:k ID

'. r--1 , _ __ _ __ _ _ _ _ __ _ _!Il_.L_______

moowred

____

"
j .:"'

processi,,!!
oe~

I
I

I I

I I
I

SUrt requNt

SFC78 call In \tie


O8JOt (OB_NO.oO)

iI , I, ,
,

I '

I, I , I I , I
~

II
I' ..
I" Iff

I' ,

'J! I1

:':
I

110 I" 111

I'~

~.Iuo.

'" 111, Ife7. poramo""

Fljl.ore 20.7 Calling SFC is withlll rho

o'il~ni:<ati()fl

block 10 \>0

m~ .. urcd

20 Main Projram

Prot..,tioo level I

, ,

o r in one of the blocks called there . The initial values after a STOP-RUN transition are - I. LAST RT indicates thc ruonroe in mt<:roScCo ndl; of the last completed OB e"ceution (e,,_ ample . . and @) _ I f the SFC is called again in the OB to be mea.ured. -I i. o utput (e ~ampl c is)}. The "n~t" rumimes IltC" outpUt; interrupt times caused by h;~er priority classe. are oot inoluded in LAST_RT (">lample ). LAST_ ET indtcates the time period in microseconds betwccn Ihe request aDd the end of pro-

ondj if funhcr. unprocnsed stan re quests are pending_ In the ClUC of the currently supplied CPU!!. NEXT_RT is nOI detenn;ned and the v.lue i. alwaY5 - I .

20.3.8 C haai'ng I"oiu", pro tection


The user program in u CPU can be protected against access ;n three protection level, (see Chapter 2.6.2 ... ?t-ol~ini the User I'Toal1lm"). ProJntm-dri,-cn touling between protection Ie-.els I and 2 IS possible ",ith the syStem function S FC 109 PR O T ECT. You can fin<J the pa rameters of thIs system function in Table 20.S. CaUing SFC 109 PROTECT is only effe..:tiv" if you ha\'e set Protection level I with the hard_ ware configuration. 11 remairu; inef'fe<:tive if Profection I"vel 2 Or 3 is set, or if. password has been ente,..,d in Protection levcl ] in conJunction Wilh the oplion Can be revoked by paS5"ord The prote ction leve l IiCt wilh SFC 109 PROT ECT ,..,mains unchanged if: :. 'he CPU goes 10 STOP due 10 a (program) error. an SfC 46 STP call, o r operator inler'enrion.
Co

cc""ing for the la81 completed e"eeutiDn o f tbe O B 1 be measured (e>lamples ([l and@) _This 0 also applies for the fi rst call of SFC 78 in the O B to be mea.urcd (@). If the SFC is called again in the OB to be measUNld. - I is output (ClCample It). LAST_ET abo contain;, tbe interrupt times caused by higher Priority classes

(@).
CUR_T indicates the rdative lime in micro~ o nds (statuS of the counter in the operating system) o f lbe Sla" request of the OBs. "'hen - as in the following ex .. mpln - the SFC 78 i. called within the OB. On completion ofOB exec ulion. Ct: R_T i ..,t to zero. CUR RT indicates Ihe effect"'e ""eculion 11mc a fthe OB in microseconds uotil cBlhni ofSf C 7 8. After completion ofOB ex e~ution. the value in Cl,-R_RT;s trans fcm:d 10 LAST_ RT and C UR R T is set 10 ~ero. Int~rTUpt lim~s cau~ed b y higher priority clas...,s ftre nol included in C UR_RT {@ andlt)). CUR_ET ind icates the tune pe-riod from the DB
SIan rc:quc~1 to tlllling of SFC 78 in mierase<:-

the CPU ;~ baltcry-backed and the mai n. supply is ,..,sI0red. Or

Co

a reSlarl is carried out (S7-400)

In all otber caseS. ProteClion level 1 is set in the c:UC of an operating mode mm.sition. Even if you switch the mode selector to STOP, Protec_ tion level I is (,..,)sct. can d etermine the Current prole<:!ion level online in the SIMATIC Manager wi th .elected CP U ami P L C ..... DLAOl'OST1C/SETfL"O"'" OPERAT1:"G MODE. In the program. you can scan the protection I""el w1\h the SFC 51 RDSYSST via the systcm st3rus list W"16>f02J2 with the 1!Ide" W"I6><0004,
VOIl

oods. A fle-r comp l~t;on of 08 e~e<:Ulion. the value in CUR_ET is transferred to LAS T_ET and CUR_ET ii set to zerO. CUR_ lOT IIlso con lains Ihe ruJ1\ime~ of the higher_priority OBs Ihat inlerrupt the OB current;y to be measun-d.
NEXT_RT indicale5
th~ time from the ne"t DB stan request to caJlmg of the SFC in microscc-

'"'

20.4 Communication via Distributc<i 110

In the case of a CPU with key loc k switch as mode selector, you can remove the key in the RUN pos ition and permit read access only by the progmrnming device during operation. In th e case of a toggle switch as mode sele<:tor. this is not possible. In this case. you can call SFC 109 PROTECT in the restan organizat ion blocks 10 activate Prote<:tion level 2, that is, write protection (read aCCess only) when swi tching on the CPU With SFC 109 PROTECT. you can change the protection level during operation without operating the mode selector. Thu . for example. with SFC 109 PROTECT you can (re)set the protection level to I wilh M ODE W# I6#OOOO depending on the signal state of a binary variable, in order. for example. to reload program sections . Then you re_activate write protection w ith MODE - W#16#OOO1.

referred to as the DP master system. Several DP master system s can be present in an S7 station . Newer DP m asters can handle tWo operating modes : DPVI and S7 -eompatible . "S7--<:ompatible" corresponds to the previous mode . With this, you can operate all DP standard slaves according to EN 50170. and additionally the "D P S7 slaves from Siemens which could al ready send interrupts to the DP master. In DPY I mode, y ou can additionally used DP slaves which exhibit the new properties according 10 IEC 61131, such as increa~cd diagnostics and parameteri7.ation capabilities resulling from the acyclic transmission of data records or the use of new types of interrupt. New sys tem fu nctions for traru;mission of data reoords. as wcll as new interrupt organization blocks. exist for the.e new "DPYI slave s". Like the central modules. the DP slaves occupy a ddre.se, in the lIO area of the CPU (""logical a ddress area") . The DP master is as it were "transparent' to the addresses of the DP slaves; the CPU " sees' the addresses of the DP slaves, meaning that the .. e must not overlap with those o f the central modules. nul e ven w ith Ihose of DP slaves in olher DP master systems assi .. ",ed to the C PU. Every DP slave has three addresses in ~ddition to th~ node addre ss , a geographical address. a module staning address and at least one diagnostics adJ",ss (Fi gu'" 20.8). Node ad d ress Every node on the PROFBLBUS subnetwork has a unique address, the node address (station number) in that subnetwork that distinguishes it from Ihe other node s o n the subnetwork. The station ( the DP master o r a DP slave) is accessed on PROFIB US with this node address. Please nol e that there must be a gap of at least I between the addresses of th e activ e bus nodes (e.g . in tbe case ofDP ma.ter and nodes in cross traffic) . STEP 7 takes this into account when assigning node addresses automatically. Geu graphlcal a ddress The geographical address identifies a module slot. With central modules. the gcographical

20.4 C ommunication yi a Dis t r ib uted V O


Distributed lIO is understood to be m odules connected over PROFIB US DP Or rROFlNET

'0.
With PROFtB US Dr, the DP maSter communicates with the DP sla vcs assigned to It OVer the PRO FtBUS sub n etwork. With PROFINET 10, it is the 10 controller which exchanges data with the 10 de vi ces assigned to it over the InduSlrial Ethernet sub neN'o rk. Th e data tran sm issio n is carried out 'automatically", you do not need to be invol ved. You configClre and address the d istributed VO using the Hardware Configuration tool in a manner similar 10 with the central modules . From the user program. yOCl can address the inputs and outputs in the stations of the distributed lIO just like the inputs and outputs of the central modules. 20.4 .1 Address in g PROFmUS DP The d istributed modules (slations, Dr slaves) with PROFIl:IUS DP are assigned to a DP master in" manner simi la r to how the centra l modules are assigned to a CPU and controlled by it. The DP master with all 'its" DP slaves is

20 Main I'rogmru

Dlllln" ..tl~ . Idd (_ _ otIr) ....

@.
_ _-

Module< DP ......
SIoto
Slot ~

_.

.. /

""VIo1u8I" .kot (not pI"l)....,.,. ",,;0''''')

'" .,., "M "'" , .,.,


~
;;B~
,,~

1020 Sla!icn 101 9 '

""""Io" ".1klI!

SIolO_..",,,, _
SI<>/ 2 ecn/a;n. 1M bu. Im..-h>oo
1M).

In ..""" modui<>

"',,_.

SJgt>III_s . . U _ In 0/01 4 and

E837

A8 506 00& .. 0
AB~!

B\"U \

Mod ....... nlnll add . ...


(&11_

00

"'.Y)

addrC!;8 comains (he number of the raek ar.d that the sl" t. Wi t~ PROfIB US DP, th~ geogmphicill addres~ conluins (nc numher of (he DP nlll&(er ays(em. the "UII;"" numlJ.er lind the slOl number.

"r

Slol numbering of a 01' ~la,c depends OD its typc. If il i. integrated u~il1g a GSD iilc. the entri,,~ in the GSD file determine Ihe sl"t a t which the 110 modules Slart. Tn lhe ease "fDP standard slaves, the 51015 for 110 modules begin al 1. Slot DWJlhering ofllll S7 sla'e is ba.cd on the 5101 of an S7-300 $Ultion. S1015 I (pow.,r supply) and 3 (c"pan~ion interface module) rellUlin empty. Slot 2 (CPU) corr~jpond.$ to the interC8.(:c module (header modul~) of the modu lllr DP Slaves. The ~ignal modulcs (SM) are poo.;itioned stanin& at s1014.1n addition. there is Ihe vinual" slol 0 (nol physically present): this representS th" comrlete statiun. It is similar with intelligent Dr slav~s. In th is casc. the tnmsfcr memory i. the mtet"f..cc to the Dr> ""'stet". Confi&UT8.lion of the transfer memory _ whicn you CftlT}' OUt with thc Hudwar.. ConfillUralion tool genemtes areas" hieh corl"C"<pond to modules or .lms. These ~jOtS do not l"C"aUy l:JIil;t. and one th~refore speaks nf vir_ mal" slolS.
Virtual ,101 0 I"C"preSCtllS the: DP <18tioll. virtual lot 2 lhe bus interface. in this case !be slave

CPU a> the heRder module oftbe DP slaw. From vinual $101 4 o"ward<. the user data "r~as are pl\:scnt in lhe transfe r memory; th ey COlT"'spond to the si&nal modules. The virtual slot. in the transfer memory are ~sem hy both Ihe mILSter and ,lp'e CPLs. The defm.ition or virtual <lots malte. It possible to dire~t1y a~.ign diagno>1ic. tlnd intemJpt events of the mlcrfllce module "r the station (see further below ~Diagnosties lidd .... ss ..). Thc srsTem funcTions SFC 5 GADR_LGC and SFC 49 LGC_GADR a1"<" available for converllion from the &eograrhical "ddr~ss to the iOllieal nddr~sscs and vice versa. and (he '}"Ilem functiOn! SFC 70 UEO_LOG and SFC 71 LO,,_ GEO ar., al'O suituble for PKOFINET 10. NOle that DP slaves which are iocorpor:a.,ed inlO

the hardware confillunltion through ~ GSD m",


according to EN 501 70 of ver!\ion 3 or latn (DPV I) c an suv'"' the user data staning at <lot I ,
Lo~ica l

a d dress..

module starli ng a ddl"l's


You use the logical addre.s t" ~ce~s th~ user dati' of a station, Each byte "f the user tiura i~ unumbiguou.ty identified by a logica l uddre~s. The logical address corresponds to the absolute liddTcs<: a ,;ymbol (Dame) Can be assigned 10 it .0 that it i~ easiertoread (symbolic addresi!ing) .

20A Communication via Distributed 110

The ",,,,Ilest logical ad d,ess of a module or station is the mooulc starting address (sec also C hapler lA, "Module Addresses"). Dia::nostic,; addu .. Modules an d stations which can deli ver d iagnostics data and d o not h ave a u ser dats address themselves are identified by the diagnostics address. The diagn"sties add..,,. occnpics one byte ofIlO input in th e logical addre " .." lum e . In the d eb ult sening, STEP 7 as,igns the diag nostics addro" starting w ith the high~ ,t address in the 110 "re~ of the CPU. You can change Iheo diagnostics addr,,"s. Th~ addre" overview io the Hardwm... Configuration tool identifk, the diagnostics addre ss by a star. Signal mod ules or u'~r data areas in \he t",ru;f~"T m~mory of intellig~nt DP slave, ha"e logi~al addresses, also for scanning d iagnostics data. Thc complete station delin"Tll its d iagnostics data via one diagnostics addres, which is "",i;;n~d to virtual ,lot O. With modu lar and intelligent op s laves, the bus interface can del iver it' d iagnostics data v ia the diagno>lics address oislot 2. Figure 20.9 shows an ~Xllmple of the dia .. tics addre,';e , in a OP master system A co m_ pact DP slave pos~es,c" one diagnostics addre.s for the compl ete s"'lion, a modular DP slave po,sesses one diagnos tic s addre ss for the stati on and onc fOT lh~ interface module . \Vith intelligent DI' s laves, there is also a d iagnostic s address [or the OP interface. Th e d iagnostics addresse, are ass ig ned in descendi ng order starting w ith the highes t 110 address. For example, \he UP interlace of the CPU J I 7-2PNIDP is aSSlg:D ed the diagnostics addres. 81 91 , the PN interface the addre ss 8190 (not shown in Figure 20.9), and the virtu al slots o and 2 in the tra "sf~r memory the addrcsses RI89 and 81 8R. It is similar w ith the ma,ter CPU: the diagnostics addrcsscs Start at 16383 for the DP im erfu ee and continu" w ith 16382 tnr the MI'VDP interface (not shmnl), 1638 1 and 16JHO for th e virtual slol:l 0 II1ld 2 of the tirst intelligent DP 'lave. 16379111ld 16378 for the second 01' slave etc. The diagnostics addre,ses for th e np slaves are a ss igned hy the Hardware Configuration tool in the sequence of coupling to the DP master system.

In th" user program , the diagnostios data are

scano ed using system b locks . The system TImetion SFC 13 nPNRM DG is " v"ila bl~ for this with conventional 01' >tandard s laves. The SFC S9 RD_REC is used w;\h OP S7 slaves in orde r to read the data record OS 1 w ith the diagnostic . data. DrYI s lav es a.., able to provide more eompreh~n,ive d iagnost ics data wh ich can be rcad with th e system filllction block srn 52 KDREC. Th e modules are addressed by m~an" of the logi cal module starting addr~ss of th~ user data or by means of th e d iag no",ics addresses. Transfer me m ory o n in telligent DP .Ia,cs In the cas e of eornp",:1 and modular DP sla.ves. the addr~ sse s of \he inP < an d OUtpnts are llS locat~d together w ith the addresse, for tbe cen!nil modules in the address volume ufthe mal<ter CPU. In the ea , e of intcllig~ m ,Ia,cs, the maste r CPU has no direct ae~eSS to the input! output m odules of the UP sl ave. Every imelli gem Dr slave therefore has a tra n.fer m emory whosc size depends on the CPU used. TIle transfer memory can be divided into several areas of di fferent len~>th and dam ~onsiSlcney. The indivi dua l areas then respond like modules whose lowest address i~ th c module starting address. From the viewpoint of the master CPU, the intclligem DP . lave then appears as a compact or mod,, 1 01' s lave. dcpt.."Ilding on 1lC the division (Figure 20. I 0).
\Vh~ n configuring thc slavc, you ~an configure the individual areas of th~ !nmsf~r memory as inp ut,; or outputs wi th the "module starting address" and the area length. Exception; if the CI' 342-5 01' provide s the DP interfac~ tor the intelli gent slave, the divi sion of its transfer memory is only configur~d when coopling to the DP ma ster system . The addresses o f the transfe r m emory must not overlap with tho.e of th~ eentrol m odules in the intclligent DP slave. T the addrcsse, are present in the process f image . the areas can b e handled by the o,cr program l ik~ inputs and outpUI:l, o\hcrw isc Hke periphcral inputs and outputs. If the s lave C PlJ possesses panial pro<:ess image . you can assign a partial process image to each area.

'1l"'-

When coupling to the DP master SY"tem, yon supplement th~ configuration a t the master e nd by the " module starting addresses" from the

20 Main l'ropm

Mu~'

CPU ((1120Pf

CP m..

'" -~~':.c:~"~"'~~~~,-.~,,=~====::tJ ' .~ '

t.,

--.
_

n....- .. """ ..... ;" IhrI moootor CPU


.wit~the

..

<l> -,~-:.

_algent OP ...""

S ...... CPU (311 .JPNlOP) 819>'


8189'
8188'

OPIro_
1$381 ' SIo"UI/IIIOn

LL.. \

I,

1&380'

Bu.in>:o<f_

'" I ::r-'"

The use, prognrm


inlhrlslaYeCPV
"""" wrtrl _

.d<I,Mse.
SI.,.. CPU jJ14(:2 0P

"""llIg.nt OP I I."" OPin_

L_ "'"~~'"',-, ' ~;.".".""""",-",~ , -,I ;:J ",Mo~ul . ,

OP .ro ....
OP~

--inlhrlslaYeCPU

The...." .."""."

addresse_

L______J---"*'"
r,
~-"'"

1~75'

S\o lIIIon

(D U<Io t-iIoIodI<c bo'I. "'~_ biolrirr _ ia .... ~of"" _ '" "'"

..

(Jl EIdIr bu. 11m............ d . . . . _ ' " - . . . . ,,'1ri<II is


OM ......

- _ I M > {_ _ k ""\',.- ... io

obi' p<rperIr" of"'" iat<rlace ill ....


<!jot "'" "Orin.: io.

- _ uI> {_

1bo

"n.

c?\.).

1_ . -1 _ - , ...

... -

II> 1b< .....,., orNI ;,. t.... _ _ Ira,......"""'"

II<Idrno wlriob ..... in .... '*'i' "rib< "",i,", ill tho ~ ... b (rlooblo oll<k ttrc: DP .1,,". <tali"" in til< Iranl""" confiJU"""'" 01 "'" DP ..... "rf .

"""'""lOt

The _ ... iJlM> urrl"o 100" Jio;ooon _ ... wlti,h ..... in .... ob,o;:t _ n i .. ~I"" .... ,;on in th. "Moo." ",b (rIoob!< '1I<k 110< "lW' Ii"" i. tiro

.II,-.UU).

.,-,,
-~

--_. - ...... -_
,

.~

r ... ___ _

- -"... . - -'-:;'~=:
__ h

F----~----. .Ii

----~.

~-

""

20.4

Communi~at ion

via Distributed 110

B 05

system
Int~,r,,,;,,

\. _~I!~_

"_""~~~ :;:::: ,"~'~':;I~I. _ 01 DPnostic. add ..." Diag {ntarfaoe


(lOOP m.aot&r)

'"

Tran.f. rmGmory
, I

" '' - _ - '

DP "aU"" ~~===~~2F: Dia~noslic"


0/

add","

of bu. ir.tillfOC8 (oJav. C P U )

Di09"",,1;0 " lIdd","

UO<Irdata . "'."

T",n.11t, m<lmo<y from

".w of

mnl ~ ' CPU

T.... n.f.' ....... mory from view of . Iave CPU

Figure 20. 10 Trnmkr Memory em inldlilr<nt DP Slaves

v iewpoint of the master CPU and by the trans_ mission dir~et;on. You assign inputs on the s lave ., ide to outputs on \he maSter side and vice versa. If the addresses are within the p t oeess im"g~. the areas ~an No handled by the U.~er pmgram like inputs and ou,p"ts, othe rwise like peripheral inpm~ and outputs . If the master CPU possesses partial pro~ess image_ , you can also ass ign a partial process image to each area. from the viewpuint of the ma,ter CPU. the "dd",,!<es o f the transfer memory must nDt overlap with ad~sscs or other modules in the (ce ntralized) S7 stalion . neither with the add",.ses Df the c<,."11tral modules nDr w ith the addre sses in Dther DP master systems ass igned to thu ma.ter CPU. Yo" alw define the diagJ105!ies add",",c, fwm the viewpoint of the inte lligent 01' slave. during configuration of these. You determine the diagnostics addresse" from the vicwpoint ofthe master CPU during coupling o f the inte lligent D P slave 10 the DP master ~ystem. D ata eon . i.tcn cy Data cDm i. tency means that a b lock of USer data is band ied a ll t ogcther. DP slaves can exhibit consistent dma areas, either as a result o fl he wnfiguration infonnation in th e OSD ftl e or - as with the transfer memory Df an intelligen t slave-through CDnfigW"8tion by the Hardware Configuration tDOI. In the Dbje<:l properties of the D P sl ave, one can set the data cDnsisteney tD "Unit'" (byte or word) or "Total" (~on-

figured area) on the "Configuration" mh. These data are tak en intD considcratiDn by the Dperating system, e .g. during Updating of the (partial) proees. image (see Chapter 1.5 .3, "Consistent User Data"). As the user, you m",! enSCIre thc con. is tency of the transmitted d1lm in the pmgram. If thc data are a comprises one, two or f<Jur byte", transmit the data as bytes. words or doublewDrds using the load and transfer instruetiDru; or the MOVE hox 'Vith an area lcngth of 3 Dr more tha n 4 byte s. usc the system funetiDn. S FC 14 DPRD_ DAT and SFC 15 DP- WR- D AT in order to transmil the data betwe en the user m cmory Bnd the transfer memory. H the addres.e s of the transfer m emory are in the process image , use th~ address area for inp ut" I or output. Q on the RECORD parameter of the SFCs , otherw ise the addrcs. area for periphera l inputs PI or peripheral outputs PQ. The system f"netions a re u sed in bmh the mer p rogram of the s lave CPU and in the uscr program of the m~sler Cl'U in Ordcr to B~ce" the data . The cDnfigur~d data areas which are transmittcd with the 'ystem funet iDns are present com pletely in the pmccss image (with n ewer CPUs) so Ihat you can also access them using IDad and transfer instruction, or the MOVE: oox. Note that Y<JU may destroy the data c<.>ru;;stcncy in the proce" StaMing from the user program of the slave CP U, you can trigger" process interrupt for a n address arCa of the tmnsfer m~mory "sing the

'"

20 Main Program SFC 7 DP_PRAL, and a diagnostics or process interrupt in the master CPU using the SFB 75 SALRM. 20.4.2 Configuring PROFIBU5 DP
m~mory). You can also configure the remaining modules later. Save and compile the ,tatioo

Proceed m the same way for the remaining stations int=ded for intelligent Dr slaves.
6) Open the master station with the DP master

General procedure
You configure ilie distrib uted I/O on the rRO F1BUS DP in essentially the same way as the centralized modules. Instead of arranging modules in a mounting rack. you a"ign DP Stations (PROHBUS nodes) to a Dr master system. The following order is recommended for ilie necessary actions' I) Creale a new projec t or open an existing one wiili the 51MATIC Manager.
2) Create a PRO FlBU5 subnetv.. ork in ilie

system and use the mOuse to drag the PROFlBUS nodes (compact and modular Dr slave.) from th~ hardware catalog to the DP master system. Assign node addresse s and, if necessary, set the module starting address and the d iagnostics address.
7) If you haye created intelligent DP slaves,

drag th e relevant icon (in th~ hardware catalog under "PROflBUS DP" and '"Already configured stations') with the mouse 10 the DP master system. Open the icon and assign the already configured DP . lave e'Connect"), assign a node address and configure lhe user data interface from the viewpoint of the DP mas_ ter (or from the viewpoint of the cemral rna~ter CPU). Proceed in the same way with every int.llig~nt DP slave.
8} Sa"e and compile all stations. The DP mas_ ter system is now configured . You can now supplement Ihe configuration with centra'ized modu les Or with further Dr slaves.

project with the SIMATIC Manager and. if required. set the bus profi le.
3} Usc the SIMATIC M anager to create the

mas\<."! slation in the project thaI is to accommodate the DP master. e.g . an 57400 station. If your system contains intelligeot DP slaves. you also cr~ate th~ relevant $Ia\'e stations at lhis point, e.g. S7-300 station;; . You start the HardWllre Configuration by opening the master station.
4) With the Hardware Configuration. you place a DP master in the master station. This can be. for example, a CPU with int~

gral DP interface. You assign the previously created PROFIBUS so.lbnctwork to the Of> interface and you then have a Dr master .ystem. YOo.l also define the DP mode in the "Mode" tab: DPVI or 57-comparible. You can also configure the remaining modules later. Save and compi le the station.
5} If you have created an 5i "Union for an intelligent DP sl av~. you open this in the Hardware Configuration and you '"plug in " the module with th e desired DP interfac~, c.g. an S7-300 CPU with integral DP interface or an ET200pro basic modo.lle 1M 1548/CPU. If you set the DP interface as "DP 81 ave", asslgn the previously created PROFlBUS subnetwork to the DP interface and configure the user data interface from the viewpoint of the DP slave (transfer

You Can also represent the DP master system configur~d in this way graphically with the Network Configuration tool. Open Network Configuration by. for example. double_clicking ana s ~b nel\\ork . Select VIEW --+ DP SLAVEs/IO D EVICES to display the slaves. You can also create a DP master syslem (or mOre precisely, assign the nodes to a PROFIBUS subnetwork) with the Net".. ork Con figuration tooL You parameterize the >lations after opening them with the Hardware Configuration. lIere too, you must first set up an intelligent DP slave before you can integrate it into a DP master S)"5tern. Con llgurlng Ihe DP master You must have created a project and an 57 station with the SllI.1ATlC Manager. You open the 57 sta tio n and create a mounting rack (see Chapter 2.3, "Configuring Stations"). Now drag the Dr master module from the Hardware

292

20.4 Communication via Distributed Catalog to the ~onfigUJation table of the mouming ra~k. You may already have sele~(cd a CPU with OP connection. In the li n~ below. the DP master is displayed with a conn~ction to a OP master system in the station window (brok ~n black _andwhite bar) . When placing the OP master module. yo u select in a window the PROFlBUS subnetwork to which the DP mast.. r system is to be ,.,sign..d and the node addre" to be ass igned to the DP master. You can also ~reat e a n~w PROFffilJS subnelwork in Ihis window. In the "ModC-' lab you also defi ne the Dr mode with wb ich the Df> master is to work. This modc applies to the complete DP master ~ys tcm. If there is nO Di' master system a"ailable (it may be that it is obs~ured behind an object or it is outside th e visible area). create one by selecting the DP maSK"!" in the configuralion w indow "nd tJ'en ~deeling INSERT ..... MASTER SYSTEM You ean change th~ node address and lh~ con nectiotl to the PROFlBUS subnetwork by selecting the modu l ~ and then making your changes with the "Properties" button on th e "General" tab under EDtT ..... O,HECT f>ROPRTIES. CP 341_5DP as DP master Ifa CP 342_50f> is the DP master. place it in (he configuration table of the station, 'elect it and then EDIT ..... OBJECT PROP ERTIES. Set "01' Master" 00 the "Mode" tab . The "Addresses" tah shows the user data addre.s occupied by the CI' in the address area of the CPU. From the viewpuint of the master CPU. the C P J42_50P is an -'analog module" with a module starting address and 16 bytes of user data. Only DP standard slaves. or DP S7 slaves that behave like \)P standard slaves, can be conn.. cted to a CP 34 2-50P as OP ma,tcr. You "an find the suitable 01' slaves in the hardware catalog under "PROflBUS OP" and "CP 342-501' as DP master" Selee( the desired slave type and drag it to the OP ma"er system. The transfer memory as OF master has a mall ;mum length of 240 bytes. It is transferred as one with the londable bloch FC 1 DI' SE}.!) and FC 2 DP_RECV (included in the Sta"dard

[/0

Library under (he Communication Blocks program). The data memory.


cons ; st=~y

cOver, the entire transfer

You r~ad the diagnostics data of the con nected DP slaves with FC 3 DP_DlAG (e .g. stalion list, diagnostics data ofa spec ific station). Fe 4 OP_ CTRL tran,fers control jobs to the CP 342_50P (e.g. SYNCIFREEZE command. CLEAR command, set operati ng stale ofthc CP 342-5DP). If you select CPU o r CP 342-501'. ViEw ..... ADDRESS OVERVIEW shows you a list of the as,igned addresses, inputs and/or OUIPUt>;. You can also SCfcen the existing address gaps. Config uring
co mp a~t

DP , Ian'.

Tk compact 01' slave, are to be found in the


hardware calalog und~r "PROFIBUS DP" and lbc re levant sub-catalog. e.g . ET200B. C lick on the OP , lave sel ected and drag it to Ihe icon for the OP master systCtn. You will see the properties sheet o f the station: here. you set Ihc node address and any d iagnostics address. Then the OP slave appears as ,m icon in the upper section of the station window and the low,,"!" ",~tion contains a coofigunuion table for (his stalion. A double-click on the i~on in the upper section of the station windu'" opuns a dia log box with one or more tabs in wh ich YOLl fiet the desired station properties. In the lower .ub-window. yo .. then ,cc (he input/output addresses. Double-cl icking on an address line shows yuu a window wbere you can change the su ggested addre'$e$. The lower sub-window shows optionally the conf<guralion table of the selected OP slave or of the master system (Ioggle with the "arrow" b utton). C onfigurin g modu la r UP slaves The modular OP slave~ can be found in the hardware catalog under -'PROFIBUS OP" and the relevant sub -catalog, e.g. ET200M. Click on the selected interface module (basic module) and drag il to the icon fur Ihe Df> master system. This SCreenS the properties shecl lor the stalion; here. you set the node address and

20 Main I'rogJ1lI'l

any diagnoslic~ addreSl<. Thcn the DP slave appean as an icon in the uppu section of the SUllion window and th e lower sc~tioD coma ins configuration table for this station. Now place the rruxl ules that you can find in the hardware catalog uml(', 'he .felected inlnfo", module (!) in the configW"lltion table. Dm:bleclicking"" the line opens the propcttie. shcct of the module and allows you !O pruameteriu the module.
Thc lower sub-window shows eitherlhc canfig-

for u '..-.anna l"' sl.8tion: insen I n S1 Stllti<m inlo the project using the SIMATIC MllTlager MId open the Hard",,,,.., ubJe~t. T>rng a mountU1Q: rack to the wind"w in the Hardwa,.., Configuralio n aod p lace tbe dcsin:;d modules. For con tiguring the Dr slave. it is enough 10 place Ihe CPU; you can add all other mudules later. Wb<.:n insertin g the CPU_ tbe propetties shetl of the PROFIBUS interface is screened. He"" you must ft'Uign ft .ubnr;1W<>1'k. 10 Ihc DP ;n.ufate and you must assign an addn'ss. If Ihe PROFI. BUS subnetwork docs nol )'ct exist in the project, you call ,"c alC u new One with the "New" b unon . This is the subnetworK to which the intelligent .lave wiU Inter be conn ected. You can open tb~ propenieuh""l of the interface by scle<:ting the DP in1Cl"fa.ce and then Enrr ..... OI:llFCT PROPEJl.TIES or by double-dicKing on the interface. On the ~Mode~ tab. select the o ption "'DP Slave". Now you can tonfigure the user dam interface un the "Conflguration lah from the viewpoint " f lbe UP ~lavc. Select MS (master/.lave confillur~tion) $S lh~ mude, Ktld detine tbe structure >md a<ldrcsscs of tbe tnmsfer intetfllce from the ~icwpoint of the slave C PU (Figure 20.11). Chapter 20.4.1 ...Addre ...~ ina PROFJBUS DP~ pro'icics information on the user data interfilce under "Transfcr memory 011 intelligent DP 5Ia,"es.
H

un"ion table of the selected 01' sia"c or of the nUI.Stcr system (toggle with the "arro,," bunnl\) .
I'ad.:inf{ addn:.ssC$
Digital cl..xtronic, modules witlJ 1"0 Oit channels... c.g. ET200S or FT200pro, initially OO;<;UPy uDe byte in the configuralion table. After Mil modules have been configured. you can US" the "I'ack add..."ses' bunon 10 remOve the )!:ap5 betv.cen the bit channels oflhe selected mudules und thus occupy fewer addresse.'. The addres, nreu for inputs, "utpul~ and motor starters a..., packed separately.
"pitcked~

Please note the following special fea=. of II module: Slot assigmnem is no 10:lger possible ; Ihe CPU cannot determine a geographical addre&.' for th;" module . No module ~ta1Us informulion for (his mod ule can be r~ad .
to a "pacKed" For thi~ reason. a d iagno;;\k, address is assigned for thJ.s module (iodicaled by italic. and &. star III the oonfiglffillion table). You can ~ceive intenupt infonnation .... de' thIs add~.
addres~.

I>

I>

> lnterrupts cannOI he assigned

The sizc and .troc!Urc ofthe mmsfcr memory is CPU-spilic. O n the CPU 315-211P, for exam_ p~e, you can divide the entire transf", memory into up to 32 addrcS5 a reas tl1<lt you can acccs~ :>cparately. Such an add,..,ss "rea Can be up to 32 b~tc<\ in ,ue. The eotire trltnSrcr memory can ha"e u p 10 244 input ad<Jr-.,:IS<;5 and 244 uutput

addres5C5. The addreSS<'.

drf~

hc-re :ott located in tbe

I>

"Pack add...,ues" an<l "loservn:rnov~ module intcrropt- arc mutually cxc 1m i,-e.

Cunfig uri"l: It CPU "lth integral DP interflloce u an inldU&enl OP ,IaH With an appropru<lely equtpped. CPU. you clLll p.a.ramcterizc tbe .Ialion ellher a..~ a DP IIlllliICf station or as D Dr s13~'e station. Before the Slation can be conn..xted as .. Dr slave 10 .. DP maSter system, il mUSI be create<l. The procedure for doing Ihis is uactly the same a, that

add",,,, volume of tlJe ~Iave CPU. ThC$e addresses must not o\erlap with a dcire,sc:i o f centralized or distribu tw modules in the f)P 91ave station. The lowest address o f a n address a,n is the "module ~Ianjng address".
Th~ uscr program in the .Iave CPU gels di agnostiC! infonnarion rrom Ihe Dr IIlaSler via the dialV'osri cs add...,ues specified on thi, tab.

You lo;nninatc configuratIOn of the intelligl'UI DP ~l"'e with STATIm< ..... SAVE _"'''D C0\1P1LE. <':onn~~ting the intelligcnl OP . lave into the DP ma.ter syslem is dcscribc:d below.

,9<

20 ,4 Communication via Distributed JlO

... ..".,,,~, , .. ,0."", 'I

-"~~-.~

....

I~'

,- ,,-

-. -. ...,
_090

11"_.. '

1
jop

ie-

" "
.oj

I>I-.-~~

~-

1 0
1 "'-

. -...- , -. _.
"~--

_ . ,

f-." ""'"

I'
I '~'

I"

"I
"

" "

--

11
, . .. R

'" "
"

FIgure 20 .11 Configuring the Tromfer Memory of an ImeHigent Slave "';th Im.gml DP Interface

Co nfigu r ing a n ET20 0pro an int.'U1ge n t DP sla\'e

a.

Configuring an ET200pro station is very simi lar to eonfigw-ing an S7 -300 ,tallon. Insen a SlMATIC 300 station in the SIMATIC Manager under the project and open the Hardware object
In the Hardware Configuration, drag the obj(X:t 1M! J4-8 CPU from the hardware catalog under "PROFIBUS DP" and "ET200pro" to the free w ind ow. or seleet it by double-dicking. On the displayed propenie, sheet of the Etherne t interface, set "not networked" ,

,ubnet does nOt yet exist in the proj(X:t, you elUl create one "'ith the "New" button. This is the subnet to which the intelligent slave will later be eOWl~ 'I~d. On the "Operating Mode"tab, seIc~t the option "DP Slave" The meanings of the addresses on tbis tab and of the addres, on the "Addresses" tab are described in Chapter 20.401. "Add ressing PROFlBUS DP" under , "Diagnostics address", Now you can configure the user data interface on the "Configumtion" tab ftom the viewpoint of the D P slavc , Sclect MS (master-slave eoofiguration) as the mode and define the structure of thc addresses of the transfer illlcrface from the viewpoilll of thc ET200pro CPU (Figure 20.11). You can find information on the user data illlcrface in Chapter 20.4.1, "Addressing PROFIBUS DP" unde r, "Transfer memory on imdligem DP slave,".

EDIT ----> OBJECT PROPERTIES in the case ofa selected interface X I, or double-dick the MPU DP interface to open the Prop~nie, window. On the "G~neral" tab. selcct PROFIB US as thc interface, and in the Propcni es window of the PROflBUS interface select the Slation ad~ss and the PROFIBUS subnct . If the PROFIBUS

'"

20 Main Program In the ~ o f Ihe 1 1$4.8 CPU, yoo ean di M vide Ihe enlin: transf.. r mfll'lo1')' imo I lOlal of 32 addn: ,9 . n: as thaI you can ace ..... $oCpBralely. Such an address a...,a cln be up 10 32 bytes in size. Th e entire transfer memory can enComp;l8s up 10 244 input addresses and 244 OUtpul
addn:llse8.

BUS $Ubnetwor1.: on Ihe "Gen....I" tab (Selecl "PROFIUC"S" in Ihe "lmerfaceOO bo~. and click the '"Amibute." bUlIon). Set the address ranges for the user d~ ta interface from the viewp<Jinl of tbe OP 51Bv~ al thi. point. Th~ maximum 5ize of the user data area is 32 byte. of inputs and 32 bytes of outputs for the 1M 151 CPU. You ~Bn d ivide this area into eight sub-areas with di fferent data consistency. The slave program receives diagnostics infor_ mation from the Dr maSter via the diagnosti cs
a~ss.

The loully defIned addn:nt'S are wilhin Ihe addre.~ vo lume of the ET200pro CPU. These add..., sseJ musl nol o verlap uddresses of The cen Iml or di~tributed modules in Ihe ETIOOpro 'Ia lion. The luwest ad<IrI:!.:I of an address 1n:3 is the " module 5tarting address". Further COnfIguralion of the ETIOOpro sliltion is carried Out in the same ,,"ay as that for an S7300 stalio n wilh fixed slol addressing. You can o nl y arrange Ihe modulel Ihal can be found in the hardware catalog undu l\.lI54-8 CJ>I;. You terminale confilluration of the inlelhlletlt OP slave wilh STAno,," ~ SAVE M.'D COMPILE. ConllC<,:linlllhe intellia;ent DP slave inlO Ihe 01' ma.sler system is de.cribe<! below. Conflllll ring I n IMI$I!CP (; .. an Inteiligeni DP sl t If you Wa nt 10 generate an 1"2ooS as an inte llige nt D P $I ave, flISt insert a SIMATlC 300 ~Ia lio n under the proj""t in tbe SIMATIC Manager and open the Ha,rI...arfl object. Now dnlg the obj"'" IM/JI/CPU umkr "PRO FIBUS 01'" and "ET200S" in the liardware Ca1alog to the free window or seleci it by doubl e-~Ii~k ing on il. If the 1M I 5 IIC I'U does not bave an ).11'1 jnlerface.the attributes window oflbe DP interface is displayed. SeleCI the node Bddress hen: and the PR OFtl.lUS mbnelWQ1'k (or generate onc and assign il \() the 01' interface). You will iICe a confiiUT8lion table like the ooe for a S IMATIC 300 ~talion. The inteHillenl 1).1 15 1 of the ET200S station is present be", instead oflhe CPU . Double-clicking on the lVl 151 Hne o~ns the window for \he 1M pro~rtics; double-clieking on the DP interface opens the propcTlles "'indow of the interface. If you have not already done so, 'el the node addresses and the PROFI -

Funher CQ1'IfIgumtion of the ETIooS 5t&lIon is carried OUt in the same way as for an S7_3oo stallOR wilh fi xed lilot addrcss inll . You Can o nly arrange tbe module$ listed in the Hardware Cataloll under "ThO[ 15 I!C PU . Scl""t 5TATIO:-; ..... SAVE M."IJ COMP1LE to conelude confIgurinll the intelligent DP sIH~e. Imeir8tion of the inte llillCDI Dr slave into tbe DP lPast ~ r ~y~te m iii de~cr i bed fim her bc low. C<m fli\uring In S7-300 stado n ... IIb C I' 3'(l-SDP a. all inttlJige nl . Ia,e [fyou insert an 57.300 ~t ation in the SI~1ATlC :.,ianager. open Ihe !Iardll"a,.., ohject and confiilurc a OOnonn~I" 57-300 station. Among oth er things, you lrnmge a CP 341-5DP communicatiOnli processor in tbe eonfiguration table. When in.minll the station, the properties sht oflhe DP interlace appears; the subnetworl: to whit:h the intdligent DP ,lave is later to be connected is 10 be assii'!oo to the 01' interface he re and you must aloo ,uian tbe nod<: address. To opm tbe propC1"lleS "indow, ,..I"t the CP 342.5DP and tben Eon ..... OBJT.CT PROPERnts. ordouble click On the CP 342.S0P. Selc~t the option '"OP Slavc" on the "'Mode" tab . The "Addres~" lab 5hows the user data inlerface from the vi"""'potnl of the .Iave CPU (Start ing address and 16 bytes in leDgth). The size o f lile Imusfer memory on the CP 341-501' as DP sln"e is up to 86 bytes. and you can divide this into different address IlI"cas aft..,. connection to tbe master system. STATION ..... SAVE M'D Cm{PILE Icnninales CQ1'IfIliuration of the intelligent OP $)8ve.

".

20A Communication via Distributed t/O

Co nn e cting an int ell igent DP slave to a DP master You must have created a project and configured Dr master station and the intelligent Dr slave (in each case al lea,t with the Dr imcrface). The DP master ami tbe DP s lavc must be configured for the same PROFffiUS subnet;v.'ork.

this PROflBUS subnetwork arc listed on the "Connection" mb. Select the desired slave and click on the "Connect" bulton. The active connection is then sho"'ll further down in the Same dialog box. 'Vhen the DP slave is selected, its configuration table is shown in the lower section of the . talion window. Now you structure the transfer memory: select the "Universal submodule" rrom the h ardware catalog (un der the CP used), drag it to a line on the configuration table. or select a line and double-click on the "Universal submedul e'. You p lace one un iversal submodule for each individual (consistent) addrcss area in the transfer memory: the maximum number is 32 . To open a window in which you define the propertie;; of the addre ss area, select the universal submedulc and then EnrT ---> OBJECT PROP_ ERTIES. or double-click on the line in the table ; space. input or output area or both . Detcnninc the staning address and the length of the area . The addresses defined here are located in the address area of the master CPU. An area can b e up to 64 bytes: the maximum overall size of the transfer area is 86 bytes. If a CP 342 -5DP is the DP master, structuring of the transfer memory can be omitted because the CP 342-5DP transfers the entire transfer area m one ptece When d ividing the transfer memory. you arrange the address areas together without gap' staning from b}1c 0. You acce$S the ~'T1tire assigned transfcr memory in the slave CPU with Ihe loadable blocks FC I DP _ SEND and FC 2 DP _RECV (included in the Standard Library under the Communication Blocks program). The data cons istency covcn; the ent ire tran.fer memory.

Open the ma.tcf station; u Dr master system (brohn b lack-and-while bar) must exisl, if not. create it with Ix ,I;RT ---> MASTER SYSTEM .
In the hardware catalog under "PROFIBUS Dr" and "Configu red Stations', you will fmd the objects that represent thc intell igent slaves : "CPU 3lx" or "CPU 4 1:><" represC11ts S7-300 or $7-400 slations with an integral DP slave, "ETIOOpro/CPU" and "ET200S!CPU" reprcS~'T1t stations which were configured as DP slaves, and "S7-300 CP342-5 DP" t epresents 57_300 ,tations with CP 342-5 as the DP slave i~tetface module. Select the desired s lave t)--pc: and drag it to the DI' master system .

CPU, ET200pro or 12005 as DP slave


Dragging to a Dr master sy,tom Or doubleclicking on the DP slave opens tbe properties sheet. The slaves already configured for this PRO FIBUS subnetwork are listed on the "Connection" tab. Sclc~t t~c desired slave and click on the "Connect"- bUllon . This causes the active connection to be carried oUl at the bottom ofthe same dialog box . On the "General" tab. yow set (he diagnostics addr~sg oflhe DP slave from the viewpoint of the master station On the "Con(ig"ration" tab, you now set the addresses of the user data interface from thc viewpoint of the DP master. The output addresses on the master arc the input addresses of the slave and vice versa. Chapter 20 .4.1. "Addressing PROFIBUS DP" contains mOre infonnation on the user data int erface un der "Transfer memory On intelligent DP slaves"-

On th~ "General" tab, you set the diagnostics address of the DP slave from the viewpoint of the masler station. The diagnostics data are read with FC 3 DP_DIAG (in the master station).
Chapter 20.4.1, "Addressing PROFIBUS DP" contains mOre infonnation on the user data interface under "Transfer memory on intelligent DP ,laves".

CP 342-5DP as DP slave
You open the properties shect by dragging to the DP master system Or by d<Jublc-dicking on the DP slave. The slaves alftady con fi gure{! for

20 Main J>roaram Conngu ri ng


Ih~

DPID P coup ler

VP/ASj Link 20 "Drag'" the Dr AS; Link 20 from the hard""arc cataloa to tbe bar ofthc PROFlBUS DP master system. In the displayed windows. define fiTSt the pn:SCt configuration ( 16 or 20 bytes), and !hen Ihe node addre", . On the DP/A S-i link 21), you eRn define 16 bytes of inputs/outputs as the selpoim configu_ ration. with an addi1ional 4 bytes for control conunands . In the latter case. the lower s""tion of the windo,,' in the Hardware Configuration suggests 16 bytes of u.ser data with addressc5 in the process image and 4 bytes of comman<ll with addresses from, c.g. S12. Sel""t the DP slave and then EDIT --+ OBJECT PROPERTIES, or double--click on the DP slave, to opcn a window in which you Can ehanae Ihe addresses suggested by the Hardware Confign_ ration and also set Ihe subprocess image. provided you have a suitable CPU. Select the DP slave and then EOlT --+ OIIJECT PP.OPER TIES, or doublc--click on the Dr slave. to open Ihe slavc propenics window. On the "Parameterize" tab. you set lhe parameters of the ASi slavC'S. with 4 blls for each slave. DP 'AS-i Link Ad"anced "Drag" the DP AS-i Link Advanced - e.g. the double rnast~ 6GKI 41S-213A20 _ from the hardware catalog to !he bar of the PROFlliUS DP master system. [n th.., displayed window. set the propenics of the PROFIBUS inK.,.face. A ~onfigurntion I8ble with the AS-i inlerfaces and AS-i slaves for the two masters appears_ Now selthe address area under which you want to access the ASi slaves from the user proilfMll. EDIT ... OBJECT PROPERTIES with a se lected AS-i master interface (in the COnfiguralion table), or double-click on the master hne to open the propenic-s dialog. On the "Diaital Addresses" mh. set the start address and lhe area lengths reserved for inputs lIDd ootputs. This tab also eontD.Jru the "Pack llIld "Son huttoM with "lUch you can optimize the ad<ircss aSlli gnments after yoo ha'-e coofia;ured the AS-i sla\cs.
H

The DP/OP coupler connects two PROFIIlUS subncts. It is configured as a modular Of> slave in caeh ofm., two liubnets _

f>rcrcquisHe: Both subnets, each "jIb a DP maSlcr system. muSl bc configurcd. Open one ofthe Slalions w,lh Ihe DP master. In tbe hardwart' catalog under "PROFIBUS Dr" nnd "Network component .... you will find Ihe DPI DP coupler. Release 1 that you can dralillo lhe DP masler system with the mouse.
The properties sheet of me PROFlBUS inler_ face appeaJ"ll on wlUcb you set the node addre$li. You II<:t the diagnostics address and funhe. paramelers on the "Parame!en;~ tab in !be object propenies oftbc DPIDP coupler.

With a $elected DPIDP coupler. the configuralion tablc for the t"'!!.'i fer memory appears. Now "Coon.,.,t" the desirt'd modules listed in the hardware calnlog under DP/DP coupler into the configuration table. without gaps and s1arting u\ SlOt I. You ~an set tbc universal module to the desin:d number of inputs and outpUts. The uscr data addresses tha! you spedfy in the module propenic! are in the addro:ss are. of the opened Dr master CPU . Configure lhe seond pan ofthc DPUP coupler in lhe .same way. The structtIfl' of tbe tfamfer memory must agree with that of the first part. Please note that inputs on one side are outputS on the other side. and vice VcrM. The addresses in bolh parts of the DPIDP coupler arc oriented to the address assignments of the relevant mas ter CPU and can differ from each olher. Configuring t he DP/AS-; lin k You eonfi auTc lhe DP/ AS-Interfaee link like. modular DP slave_ Yon will find th~ moduks that yoo can drag 10 the DP master system. such as the DP/AS-i link 20 below. in the hard W8n' catalog under "PROFlliUS 01''' and ';DP ASi", Then yoo set the propcnie! of !he DP section aod configure the AS-i sla,es dcp<.:odina on the link on the propenics shel'! o r in the configuration tabie_ The AS; master sy5lem with the ASi sl."es is not displayed as a subne. by the hardware confiiUTRt;on.

No", "drag" the placeholder for lUI AS; slave positioned under the link frorn the hardware

'"

20.4 CommunicauOll

ViM

lJi'lJibuted IK>

~-

-'._':,=~=::;~~::::r'~'~'~'~=====::~n
II_ ~
:I Ill_ I, ,. 3
e-o '

~-.-

r ll'--~""""''''''

--

-,

_ F ""

.... R_"'.....
"0.0 , ."

calaloij to Ihe configuration lab le . R~at Ihis procedure for all scheduled AS_i .Iaveo. EOIT-I> O!iJTT PROI'F.RTTE~ with a selected AS-; !lav'" (in the configuroliOD lable). Or double-click on th'" slave linl' 1 oJ>C'o the properties 0 dialog. Sct the slave proJX'nil'5 on Ihl' ''Configuration" lab. Clid "Selection- [0 view all the AS-i sillves Jtnm,.."II to the HllI'dwarc Configuration (Figure 20. ]2). 20.4 .3 S p, clal Functions for PROFlBliS 1 )1>

OPTIONS -I> INSTALL GSD FILS in the Hardware Configuration and specify the directory of Ihe aSD file or another STEP 7 project in the window thllt ..ppears. STEP 7 accepts Ihe GSD file and displ ays Ibe slave in thc hardware catalog under "PROFIDUS DP" and "Addil;onal Field Devices-',

STEP 7 save. the GSD files in the di,..".,tory , .. \Step7\S7DATA\ GSD, The OS O files deleted when inslalling or imponing al It IDler lime arc slor~d in the subdirectory ",\tiSD\DKPx. FroIO h~re, they ~an be restored wilh OM'!O}.'S -I>
INSTALL aSD FILE.
Conn ~urlng

Gsn tIIn
You can "post ;nstal!" DP slaves that arc 001 included in the modulI' Cala]og. FOT this purposI'. you requi...., Ihe type file taIlored to the sla~'e (O SO file. General Station Description. device database file). From GSO ,'enion 3 onwards, DP slaves in.talled w,lh a GS O file ,uppon Ihe DPV I functionality. Sele\:\

SYNClFR[Zl: grollps

The SThC control command caliSCli the DP 51Bv.",. combined as a f'OUp 10 OUlput their oulput stales s.imuhanoollsly (synchror>ollsly). The FREk:ZE conlrol command causes the DP slows combi ned as a group to "freeze" the cur-

""

20 Main Program rent input signal s!ates simu ltaneously (syn ehronous ly). in order to allow them to be then fetcbed cyclically by the OP master. The UNSYNC and UNFREEZE control command, revoke the effect of SYNC and FRE EZ.E respectively,
It is a requirement that the OP ma<1er and the

8m"P (see Chapter 20.4.7. "System Blocks for


Distributed 110"). The DP ma ster then sends the relevant command simultaneously to all DP slave, in the s!",c ifi ed group You configure the SYNCIFREEZE group 8ft~r configuring the DP master system (aU DP , lave, must exist in the DP master system) . Selecl th~ DP ma<1er system (broken black andwhite bar) and sel ect Elll'f --c, OBJECT PROPERTIES. In tbe wllldow that then appears, you first establish on the -'Group Propenies" tab the group commands ' 0 be executed (Figure 20.13). then you assign the DP slaves to the individual group s on the "Group Assignment" tab.

OP ~laves have the relc \'am functionality. from the object pcoperties of a 'lave. you can see which command it s uppons (sele ct DP s\ave. EVIT --c, OUJECT PROPERTlS. "Generar' tab under "SYNCIFREEZE Capabilities"), Per OP master system . you can form up to 8 SYNCIFREEZE groups that arc to e"ec ute either the SYNC command or the FREEZE command or both. You can assign any DP slave to a group; on thc CI' 34250Pofa spe<:ific ver sion. onc DP slave can be repre,ented in up to 8 gcoups. When you call SFC 11 DPSYCJR. you cause tho ...set pcogram to output a conunand !O a

Here you select each of the DP slaves listed


with its node number o n~ after the other and , e lect in each ca ,e the group to wh ich it is to b~long . If a DP ,lave Cannot exe~me a specific command. such as f REEZE, the groups tbat

, .. ,",. , 'H ~ ~""".~

13

-. -, ._,
- 1

-,

0_
p~ p~
p~

"'-,,,, '" '"'''''' 1


r_~

i''''''

"

... ..... ~ ..... _

'" ""EZE

"-=
p ~=

, ,
~

~~~

.,., .
~ ~x ~~~~~

13

p ~

I,

-, -,
~

F7 "'0;:

rv

""IZr

P .n.C

'" "''''''"

!iI'" ' " ,0'1.'

Figu .. 20.13 Configuring SYNC ""d FREEZE Groups

"'"

20.4 Communication vi" contain this command Cannot be s~lected, e.a. all groups with the FREEZE command. Tenninate conJiaurinll of the S'0oIC/FREEZE groups with OK. Please nOlc that when configurina bus cycles of the same length (c-q~iJ istant), group s 7 and 8 acquire u ~pccia l meaning. Co unll u rlng PROHBUS PA For confi"urinK a rROFffiUS PA master system Ind for parameterizing the PA field devicn, UK the Ilardwarc Configuralion 1001 (STEP 1 VS.l SP3 Dnd lat~) and thc SU>1ATlC PDM optional ,olm"n: (with an earlier 'er1ion of STEr 7). With the Hard".,.re Confi&uration, you build up the connection to tile Dr master syStem with the DP; rA link: in the Harowan:: Catalog under " PROFIBUS DP" and "Of>IPA Link'", draa the I:YI 157 interfac~ mooule to the OP master system. With the OP slave, a PA m~ stcr system is simultaneously created in its own PROFIBUS suhnetwork (45 .45 kbi tsls); it is indicated with a broken black-and- white bar. The OPIPA coupler transfers the data unmodi_ fied and uninterpreted belween the bus systC1l)S; for this rea.;;on, it is not parameteriud. The PA field devices ace addressed by the DP m!ll>ter. They can be incorporated as DP standard slaves into thc Hardware ConfiaUTlltion of STEP 7 via a GS D file. Following thi . you will fllld the rA field device. in the Ium;Iw.re catalog uude!" "rROFIBUS DP" =d 'Other Field D"Yices". C onfiguring direct dala exehanllc (slaH-Iu-slave ~omn' unlcation) In a OP mailer sySlcm. the DP master h8~ exclusive control ovcr the slaycs assigned 10 it. With appropriately equipped stations. lUlotb~r node (master or inlellii:eIlt slave, refe~d to 8:i the - ",ceivC1"-- or "sub'ICribcr") Can monitor the PROFIBUS subnetv..ork to learn whicb input data a DP slave ("'scllder" or "publisher-') 15 sending to "ilii" roaster. This direct data ""challge is al50 call ed "lmcral communication-. In principle all Dr sl""es from I specific reyision level can function as senders in direct data cxehanlOc.

Di~tributcd

1/0

You configure direct data exchange with the Hard,,-sre Confivuration in the I'ropcnies willdow of the DP slave (rec~ivcr) ",hen all the 81atiolU on thc PROFIBUS subnetwork arc con_ nected. O~n tbe re<:eiyer station and SClcctthe Dr interface and then EDiT ... OHl&:T PROPEI!: nFS. The "Configuration" tlIb comains the transfer interfac e betw~n til e DP slave and the Dr n,aster. Click the "New" button. a nd set OX mode (direct data exchange) in tile con figuration windn ... which i. displayed. Al50 defme the parameters for the Dr parmer (sender) in the same window. You can al'" USC dire<;t data ,,",chanae betw~-(."JI two DP master systems on lbc:: $&IIIe PRO FI BUS subnetwork . For example, the master in master <y>;tem 1 Can monitor the data ofa _la"e in mISter system 1 in Ihis way. C onfiguring co nstant bus cyelc tlmt'll and hochron ~ mode

Eq,,;d;u,mce
Normally_ the OP maSler control tllc or $lay1.'8 IJsia;ned 10 it cyclically without a pause. With S 7 Communication, such as when the PTOIo'Tllmmma deyice executes modify function!! yis the PROFIBUS subnety..ork.. this ellll ",suit in ""riations in the time intervals. If, for example. tile outputs arc 10 be modified yia DP slaves at a regular inter>'al, you can SCI cOllStant bus cycles with the "PP'op, iately equipped DP muter. For this purpose. tbe DP master must he the only Class 1 maslo.--r on the PROFI8US subnetwork. Constant bus cycle time behavior is po .. ible with the bu. profiles "or " lind "UserDefined" . The PROF!BUS subtle1 ,"US1 not be project-wide and no IT ~ystCtn or Ci R (Config_ uration in Run) object may be connected. If you conftgUre SYNC!FREEZ E gmups in addition to Ihe constant bus cycle time, pleas.: nOle the fonowing:
:>

For DP slaves in group 7, the DP masler automatically initiates , SYNCIF REEZE command in every bus cycle. Initiation per user program is preYCDted. Group 8 i. used for the constant bu, cycle time signa! and is disabled for DP . laves. You cannot configur<: con~t .."t b",. cycle

Co

'"

20 Main Program time if you have a lready configured slaves for group 8. Between completion of the execution of Ihis OB to the next global control command there must be lime for execution of the main pro_ gram.

Isochronous mode Reference is mOOe to isoxhrone mode if a program is cx,..;uted in synchronism with the PROFIBUS DP cycle. In conjunction with constant bus cycle times. this results in reproducible response times of equal length to the 110 that include distributed signal acquisition. signa l transfer via PROflBUS and program execution including proxc.s image updating. The user program executed in i'oxhrone mode is present in the organization b loxks OB 61 to OB 64. The system functions SFC 126 SYNC_PI and SFC 127 SYNC_ PO are available for updating of the process image in isochronous mode (see Chapter 21 8. "Synchronous Cycle Inturrupts).
Figure 20 .14 shows the timen; involved in isochronous mode. is the lime required for re ading in the process values. It contains the execution time in the input modules or electron ics modules. and, in the case of modular DP slaves. the tr~ru;fer time on the backplane bus. At the end of 11, the input information for tnmsfer using !he global control command is avai lable. Then the equidistance time begins. It is the time betw""n two global contro l commands and cncompasses the transfer 10 the subnet as well as the execution of the isochronous interrupt OB .

To is tbe time required for outpUlling the pro cess values. It begins ""1th the globalcontrol command and comprises the transfer time on !he ",bnet as well as the proxessing time in the output modules or electronics modules. In the case of modular Dj> sla"es, tbe transfer time on the back--plane bus is also added. The re sponse time in the case ofisoxhronous mode is the tOlal of the limes n, equidi,tance time and To.
Correspondingly dcsigned OP ,laves allow a reduction in the response time thanks to overlapping iso,'hronous mode. This involves overlappin g updating of the inp ut and OUlput signals (overlapping of 11 and To). In this case, you must deactivate tbe cbeckbox "Times Ti and To ideotkal for all sla'-es ' 00 the "Equidistance" tab , and enter the individual rimes for the participating modulcs. If isoxhronous modules have both inputS and outputs. overlapping of and To is Dot possible .

Configuring ri,e isoehrono"s mode


A prerequisite for configuration of the isoxhronou, mode is the equidi stant behavior and the corresponding functionality of the participating

------ -- ---- Input

Main prog ram

tsochronous mod" os

l
~

Matn program

-----

0'

-----

GO

\ OC

I
SlaY<!

\1

11

--

ISta"e 0

Acyclic Acyclic services

1~~I ~nE ~~enSla~ 11 ~ ~


Reserv&ci for equidisrance

ISlave n

- - - -----Output

Cyclic data transmission

"
Change in sensor slg nllt lit the modu l8 termina l
Figu.~

DP cyet. tima Rupcnse Um a with tace-hrcncus mod.

'0
Output at the modu le termtn al

2 0. 14 Re.poru;. Time with Iwchrone Mode ond Con"ant Bus Cycle Times

20.4

Commu~ i cat io~

" i" Di.teibuted [/0

r-T.....
, .., ' -"'0

""'

__

1>'-'" "" _ ...-""' _, .LBo 10 ( . - """",,_l


( ....; . = m ........
-,~

= ...

<><-

J I --

ftg ure lO. 1S jsochrono u. mMe:

o,'ervi ~w

of DP ,Ian pWp"r1ies

D P components. Following configuralion of the DP master system with appropriate mooult:s (CPU w ith integral DP interface as well as ET200S and/or ET200M DP interfa~es with the input/output modules), as,ign the priority. the D P master system and the partial proceos images to the organization block in the CPU propalies on the "Synchronous cyc le imermpts" tab . To sw itch on the constant bus cycle times and jsochrone mode, m ark the DP master interface in the CPU and .dect EDIT -4 OBJECT PROPE flTIES . In the disp layed dialog box, click the '"Properties " bunon i.n the "General"' tab . In Ihe properties w indow of lhe PROFlBUS interface. select the "Netw"rk setling'" tab. Note that the constant bus cyc le times properties can only be set with th~ bus profi les '"DP " and "Us~r-de fined" . Clie k the '"Options" bUllon an d the se lection box" A ctivate constant b us cycle times" in the oplions window which is then displayed. For isochronous mode . specify addi tionally Ihe time~ Ii and To. Either seleClthe "Time< Ti and To same for all s laves" Or set the limes individually in the slave properties.
a~h module partic ipating in isochronous mode must have an address in the partial p roce ss im-

age thut has been assigned to the isochronous or ganization bl""k in the CPU peoperties . Set the partial process image for the module in its peoperti". dialog box on tbe "Addresses" tab The isochronon, modnles must be made known to the DI> imerface module. In the properties window o f the DP .lavc. a~\i va\c the option "Synchronize DP slave to constan! bns cycle time Of> cycle" on the "lsochrone mode" lab. H"re you also select tbe modules or electron ics modules involved in isoehron ous mode. To update Ti and To, select the properties oflhe D P ma5ter system, then the (suhnet) properties, and th e Opti ons" bnllon on the 'Iernork settings" tab. Wbenthe "Recalculate" button is ac_ ti vated. STEP 7 upJates all time, involved in isochronous mooe . Yon ca n modify the suggested equid istance time but no! below the displayed minimum time. The "'Details" burton shows the individual proportions ofthe eqllidistance time . Plea,e note thai the cquidistance time increases tbe more programm ing d evices are cOlUlecled direelly to the PROFlBUS subnet and the more intelligent DP slaves arc in the DP master system . EDn -4 ISOCIiRONE MODE g ives you an overview of all componenls involved in isochro-

20 Main Program

nouS mode and Ih~ releY" tl l parameters (Figur~ 20.15). Tflhe checkbox '"Times T i and To sam e for all slaves" under ." elw ork s~tting," and "Ortio ns" has bc<'-"Il deacli vated. yon can sel the update tim,," individually for ca~h sLwc (pre requisite fo t overlapring isochmnoos mod~) Sebo l Ih e DP <lave in the '"lsochrone mod," w ind ow. "Edit p ~nuneters" provides you w ith a dialog window fo r ~",,'eri ng the individual urdat~ times and (he modules involved in i';oeMono"S mode.

address arca) . The 10 contro!kr is SO to say 'transparent" ror the ~ddresses o f the 10 devic~ , : tbe CPU "",cs" tbe addresses ofth~, 10 device> so that these addre,.,es mllst not overlap "ith lhose oflhc central modules, not even with those of DP sh,'es in the DP ma't~r systems as,ig ned to th~ CPU. Eaeb node operaTed on The Indu,triai thcmc~ h as an TP "<kin,S.>. This i, as~igned dllring configuration of<hc TO ~<Jntroller. The IP addresse s for th~ 10 device, are derived from the I t' add",% "r the 10 controller. In addition, all TO device i , assigned a device name, a device number (node nwnber), a geographical addres~ (slot) and at least one diagnos~ies address (Fig-

2004.4 Addres. in !;!: PROFl.'\'ET 10 Tn a manner <im ilar to how centtal modules are assigne d 10 a CPU and controlled by it_ th e dis tributed lll(xiuk s Wilh PROFIN ET 10 (Slation.>. TO devices) are a" igned 10 an 10 <;<mtrol kr. TIle 10 eonno!ier with a ll its'" 10 de,-iecs is ref~TTed 10 as a PROFTNET 10 'ystem.
Like ~cIllrai modules. Ihe 10 d~viecs occupy addresses lD the C PU's I/O area (" logic~ 1

ure 20.16) .
i\lAC addr....

The .\1AC addres> is an addn'" ass igned to lhc d~\'ic~ whic h is g loba lly unambiguous. Tt con-

(.,.rt of ,p ... ",. . .)

_odd,...

~ ...... ' ... ua" . ,ot

(net ph""",,,,, ",_nil

S'<)\ 0 "'0rM6nlS \

-'-"r~'

02 ( ~.

10 d Ie. (ET 200M)

"

~~,

~_.__

e,M'

X~ .'" !II_ Pf>.ro"" """"

eemplo,. ,"'on

""M'toce.
n"mb~~

tr~

,p "''''' ' '

D","oo nu"'''',
(ato;""

! ,
' 'Skl!OX,
Srot OX1 P'
(~"")

Lov''''' odd,n . aocr,,,,")


(""'" <lata

~SIot2 ,
r Sio! ,

S ~ot

ct''''

;CpuI 01

D;,;:toI 00'''''' DO

2004 CmnmW1ication via Distributed

va

aelers and cons ists of len .. rs. digits, hyphens and dots. The name of the 10 system can be appended to the d evice name, separat.. d by a dot. To do so. s~lect "Us e name in TOfDeviceiControlier" iu the properties oflhe PROFINET 10 syst~'IIl..
Nod... ddr ....

,
of 11' addr.ss struCture

The .ubn<:t oddr<:,. is pro.ent left_justified in t~~ !P address . nd i. !!cnrnl1ro by AI><-ni~ tho IP odd",,, with tlle subnet ma.>k.

Supplementary to the device name. the HardWare Configuration also assigns a dC";ce number to each TO device which is independent of the IP address and which you can change. You can usc Ihis device number (station number) to address the TO device from Ihe user program, e.g. as an aemal parameter on a system block.. G col:raphicaT address

Figure 20.17

Exomp l ~

siSls of three bytes with the vendor ;dentifica. tion and three bytes with the devic e identification. The MAC address is usual ly printed On the device, and is assigned to it during the configu_ ration procedure (ifnOl alre~dy done in the fac tory).

The geographical address identifies a module slot. With central modul..., the geographical address contains the number of the rack and th at of Ihe slot. Wilh PROFmET 10, the geographical address contains the number of tbe PROFJ}."'ET 10 system. the 8lalion number, the slot number and possibl y a subslOl number. The "virtual" s lot 0 (not physically present) repre sents the 10 device . From slot I onwards are the user data and diagnostics dala. The sy,... tern functions SFC 70 GEO_ LOG and SFC 71 LOG GEO are available for conversion from the geograpbical add",ss to tbe logical addresses and vice versa . Logtcat address, modulc s tarting address \"ou u.e the logical add", .. to Rccess the use< data of a slation. Eaeh byte of the user data is unorubiguously identified by a logical address. The logical address corresponds 10 the ahsolute address: a symbol (name) can be assigned to it so that it is easier to read (s)mbolic addre>sing). The smallestlogica] add",.," ofa moduI~ or station is the modu le Slalting add", (sec also Chapter lA, "Module Addresses"). Dl a gnoslTu "ddress Modules and stations which can deliver diagnostics data and do nOI have a user data address th~mselves ar~ identified by the diagnosli~s addre" . The diagnostics address occupies one byte of petipl1cml inpul in the logical add",., volume. In the default .etling, STEP 7 assigns the diagnoslics address starting with Ihe highest

lP addO'",
Each node On the Industrial Ethernet subnet work which uses the TCPITP protocol requires an 11' address. The IP addr~ ss must be unambiguou. on the subnetwork. It is a"igned once to the 10 ~ontroller for the nodes ofa PROF1NET IO system. Basedon Ihis. the Hardware Config uration assigns Ihe 11' addresses to Ihe 10 devicn in a,cending order. The IP addres, i, four bytes long, each being separated by a dol. Each byte is represent~d as a decimal number from 0 to 255.
Th~ II' addr~ss comprises the address of the subnetwork and the address of the node. The s ubnctwork mask defmes the share oflhe network address in the 11' address. Like the lP address. it consists of four bytes whieh can assume a value of255 or O. Those bytes with a value of2.5S in the subnCt\<-'ork mask defme the subnetwork address. Ihe byte. with a value of 0 define th~ node address (F igure 20.17).

Device name, device

numb~r

During the configuration process. you assign the 10 controller and e ach 10 devi ce a device name whieh must n01 be longer than 127 char-

aoddrH, in the 110 area of the CPU. You can chanae the dbgnQli1ic$ address. The address ~'erview in the Hardware Configuratioo tool Idenlifies the diagnostics address by a star_

etar' tab. You can also configure the remaining modules laler. SD and compile "e the stalion.
5) Using tbe mouse. dtag Ibc PROFTh.'ET nodes from tbe hard""are catalog to Ibe PROFl}.'T [0 system. Assign tbe de"ice names. ""ith 1M nllll1bn" (su,lion nwnber) if applicable.
0) If you use IRT commurucation. create a new sync domain. accept the plU1lcipating PROFINET 10 systems. lind set the properties of the relevant devices.

In the example shown (Fiaure 20.16). tbe MPL DP inlerface of .he CPU 317_1PNIDP is assillncd diagnostics address 8191. lite P'< 10 intcrfpce is assigned add,..,S$ 8190. and the 10 eonlroLler is assigned address 8189. In the 10 device. the intcrfa<.:e (,lot 0) is as.igne<! diag_ nostics address 8188. The power module docS nOt have its own user daTa. and is ass igned the addre,,!!l g? In the user program. the dillll"OSTics data are SCIlnncd u.ing sysTem blocks. Witb a dia!!Dostic ;nteTT1lPl, foc example. the SfB 54 RALR..M 15 u$Cd which read. the supplemmuuy inlermpt infonnation. You can SoC"" Ille diagnostics dalB record DSlusin/!the SfB ~2 RDREC

7) If you use IRTtop. you mUSt configure the net","Ork topology either in the Hardwa~ Configuration di1'tt\ly lllhe pon (inurlace cono~tion) or centrally with the topology editor.
8) Save artd compile aIl5u,tions. The PROF!-

20A.S Conflgurin/! PROFIN ET 10


General proeed u .... You configure tbe distribuTed LO an PROFI NET 10 essentially in the 5BIlH: way as tbe centn.liud modul cs_ IDJltea<! ofanat:lging modulei in a mounting rack. you assign 10 devices (n<.>des on the [ndustrial Ethernet subnctwork) 10 PII.O f lNET 10 system. The follo"ina order i. ",commended for the necessary
!\Ctioll~'

NET 10 SYStCIn;s now confiprcd. You can now supplemenl the configuratioo w ilh cCnltalized modules. with DP master sy'telDJI or further 10 devices, You can al<o represent the PROFn-.'ET 10 syslem configu.-ed in this way graphically witb the r-ctwork Confii"ntlion tool. Opell Network ConfiJPlTlllion by, for example. double-dicking on a subnetwork. Selecl VIEw ..... WITH DP Suns,10 DEVICES 10 display the 10 devices. You can also c,..,ate a PROFINET 10 system (or more preCIsely, assign Ihe nodes to an Eth~met sub~t"ork) with the Network Configuration tool. You panlmeterize the stations after openina them with the Hardwa~ Configuration.
'~ce

I) Create a neW projeCt or open an existinll One with Ihe SL-'-1AT[C Manager.
2) Create a IndU$tri.1 Ethernct subnet"-'ork in the project witb the SIMATIC ManagCl".

3) Use the SIMAT[C Man'8C1" to creale !b~ Sialion in the proj~t tbat is toaccommodat~ the [0 controller e .11. an S 7-300 Station_ You stan the Hardware Configurauon by o""tUng the station. 4) With the Hard".re Coofigutation. you place an 10 connvller in the .tatiOIl. This can be, for elIampl~ . CPU w;lh integral PN interface. You assi"" Ihe p",,"~ously erealed Ethernct subneTwork to the p~ illter_ face and you then ha"e I PROFTh.'ET 10 system. Impon or modify the propowd device name and Ihe [P addre .. in the "Gen-

8<:fore loading the c(mfilluration data. Ihe de. name must be assigned to each 10 device ('"'naming" ). In STOP mode. load the cOnJtgoratioo t1au, onto the CPU that acceplll paramcters such 1$ the IP addrest. With the Hardwa~ Con_ fiauranon. load Ihe data ofth~ currently opened 5t1\l'On (PLC ..... OO"''NLO,,-O); with the NeNork Configunltion. VOlI can send the data to several stations. for ex~mple. with PLC ..... Dow}Jl.o ... n
TO c\'"Rl!.BT PROJF-CT ..... S1..'B'TI.
ST,,-nO~S

ON THI!

AI startup. the CPU uansfCT1 Ibe configuring informallon to the 10 d~'iecs and monitoI"'i thc paramcterization. The 10 dc\"ices also ~ceive their IP address with the paramcters. Following successful paramettrization. the user data ~re

;0'

20.4 Communication vi. Distributed 110 then exchanged cyclically between the 10 con troller lind 10 device, in RUN. Co nflg urin!;:: the 10
eo n troU ~r

select he.-e whelher the sy~lem name is \0 be pan of the device namC for the 10 contro lle r ~nd 10 device, . You can access the 57 subnetwork 10 uSIDg the .. Properties ... ' button. The Update time" lab sh<:lws the time span cal. culated by STEP 7 within ...hieh the 10 cODtroller has exchanged all data with illl [0 devices.

You must have created a project and an 57 sta t,on with !he STMATIC Manager. You ~n the 57 stalion and <.:~ate a moumirltl ".ck (5 ChaptCT 2.3. "ConfigunPg Stations,). When posiLioning II CPU with PN intcrfa~. cOler the II' addresses and the jUbnC1Work mask in the propenic~ window which is displayed. and nel work the interface l() an exitting or n(wly cre ated Ethernet mbnetwork . After clicking the "OK bullOO you will be provide<! with a PROF INET 10 system in the Station window (black/white dashed rail). If there is no PROFINET 10 syscem available (it may be Ibat il is obscured behind an objttt or is outside \be visible a~a), c~ate one by selcct ing the PN 10 interface in Ihe configurution windOw and then scleet;n!> rr-SEIU -+ PROFI. NET 10 SYSTEM. Mark the black/white rail. and select EDlT -;
01lJ1iCT PROPERTlliS. Aniit'! a name and an 10

Chanac the device name of the 10 controller


OWECT PROPERTIES;

w,th the PN 10 interface ~Ittted aoo EDIT --> with the "Propcnics' bIDto!l you will be provide<! with a window for chunaing the IP add,....s. the subnetwork mask and the conn oction l() an Ethcrnet subnetwork. Conflgurlng the 10 de ..lce

The 10 devices can be found in the bardw,,", cat_loa under " PROfTolET 1 IlDd lbc c0rre0 sponding subcatalog, c.II. IIO. Click on the required interface (bllsic module) and d reg ;t wing the mousc 10 tbe symbol for the I'ROFTNET TO .ystem. Duuble click 00 th e 10 device to obta in the prupenics sh""t of the st!'ltion on which you can ~t the device name and number. You ellD change the proposed lP address by clicking the Ethernct ..... button.

sYltem number (from 100 10 lIS) in the Gen_ eral" tab of the propenics window. You eao also

IU'II(.M.I'fIOff<1 Kl _ _ .... _ ......_ _ _ _ vzo ....., ..

.~-

_Pf'KlFItIII._ .... *"'"' _

.1_
x,

,_

""'1'0"'" "..... , ,,..

"
c-._ !

Flwu~

20.18 Conliguri0H tho PK/P:-I couplo:r, Connection ""d cluro"<Ie, i,tlc, of tbo tTan.fo:r in1o:rface

20 Main Program

Now position Ihe modules which you lind in the hardware catalog unda Ihe required interface ( !) in the eonfig ...ration lablc. Double dickillg on th~ line opcus the propenie, ,heet ofth~ module and permits you 10 sct the modul~ parameten;. PNfPN cou p ler ko n figuricrcn The PN/PN coupler C0!ll1e<ot5 each of two in_ dustrial Ethernet 8ubnets 10 " PROflNET 10 system. In each of the two PROFINET 10 systems, one half of the PNlPN coupler appears as an 10 device. With the configuration, you bring togClhcr the two 10 devices and panunetcrizc Ihc PNIPN coupler. Prerequisite: The two PROFINET 10 systems a re set up. The preferred method of configuring is to ,tan with the "X 1 side" of the PNIP:N cou pler. Open the relevant s(ation (Figur~ 20 . 18). You wi!l find the ,ymbol of the P:-VPN coupler in the hardware catalog WIder "PROFINET 10" and "'Gateway". Do ...b le-clicking on the symbol when the PROFINET 10 systcm is a lready selected accepts the PNIPN coupler into the confi guration. EDlT--> OIlJECT PROPERTIES with the PNIPN coup ler selecI~d shows its properties window wilh the fac ility for s~t!ing the device name and tho dovice number on Ihe Ethem~t subne!. You can change the 11' address with the "Ethernet..." burton .
In the configurat ion table Ihal is displayed wh<'-"Tl the PN/I'N coupler is selected, the slmion

To configure the Inm, fer memor)" position the univer;ul mod ulo, (found in the catalog u nder the P:NfPN coupier) without gaps ill the configuration table Starting from SIOl 1. In the properties of the univer;al m odule. set the I/O type (input area Or output area or bolh), the relevant sian address, and th~ area lenglh, a, well as Ihe assignmcut 10 the process image. You can d ivide the transfer memory into a tOlal of 16 areas whose data ar~ consistently transferred . Save the previously completed setting, with STA-

n o" ...... SAVE.


To configure the second side of the PNIPN coup ler. open the station on the other Ethernel subnet and position the PNIPN coupler from the hardware catalog on the PROFINET 10 system. Open Slot 0 of the PKII' N coupler, and set the connection panner (the already configured Se<;tion of the coupler) on the "Connection" mb . If (he subnet is in the same project, the structure of the transfer memory is transf~rred consistently. :Now you CaJI adapt the addr~sses according to your specifications and .>e1 the remaining paramelers of the coupler. If the two subn~ts are located in different projects. you must Stru Cture the transfer memory manually in bolh cases. Please note that an input on one side must correspond to an output on the other side. an d v ice verSa. With different projecl~ , you must as> ign the dev ice nam~s for both sides oflhe PN/PN coupler online. On the "Connect ion'" tab, you can al~o c lear down the connection belwcL"Tl the subnel~ again (enter "- - - - -.. und~r "Subnet"). Configurin g t he fEfPB lin k You can lind the IE/PI:! link PNlO it! the hardware catalog under "PROFINET 10" and "Gateway". Double clicking on the symbol with the PROFTh'"E T [0 system previously selected outPUIS the propertie, window in wh ich you can set Ihe e[)!mection to a P ROFIBUS subn~twork and tho node number in this subnetwork in the "Parameters"' lab EDTT --> OBJECT PROPERTIES with the [EII'B Jink s~le cted displays its prope rties window with Ihe facility for sctting the device n ame and number on the Ethernet subnetwork. You CaJl change the IP address "sing the "Ethernet ... " button .

is located m the tir<;t line in slot O. In Ihe object properties of the station. select the di~b'!lO'li~, ovents 10 be reported on tho "Parameters" tab. Tho diagnostics address of th~ stalion is on the "Adtlre..ses" lab. On the "Cotltlection" tab, set whether the "Xl" or the " X2" side ofthe coupler is currently configured. If you have start~"<l with the "X l side'" of the coupler, aJld if both subnelS to be connected are located in one project, YOli do not need to set a nything else on the "Connection'" tab. [n the object properties of the interface on slot X 1. the "Addresses" tab contains the diagllOStic, a ddress of the interface, and the "10 Cycle" tab conta in, information about the update time .

30~

lOA Communication via Distributed I/O

The TF)PB link is quasi Ute DP ma,ter for the "",,!>ordinate" DP master ,ystem. You posiuon the DP slav", from Ih" hardware catalog on this master system, and a"ign them w ith tbe desired pwpertie, (see Chapter 20A ,2. "Con figuring PROFlB U S DP") Tho DP slaves require a d"vice nu mh er in order to address Ut~m over PROFINE T 10. You can make the m>signment, between node n um ber "n the PROHBUS and device tHlm bcr On the PROHN T in th~ properti'" window of~he lEI PB link the "Device num~r." tab. As standanl, STEP 7 uses Ute PROFlBUS addres~e~ as th~ d~vice numb<., (indic"ed by a s tar on thc d~vi~~ numb<;r). Sck~t a DP . lave in Ute h s\, 1IIId ~liek the "Change" button.

20A.6 Spedal Functiolls for PROnNET 10 GSD flies You can "POSt instaU" 10 d"viccs that ar~ not in cluded in thcmodule cata log. For this p"'pose, you require the type file rilored to the 10 device (GSD tile. Generic Station Dcscription) . Su itable for 10 device s are GSlJ nle s of version 5 or later in XML format (GSDML O"n"';c Station Description M arkup Language). Select OPTIO~S ..... INSTALL GSD FILE in the Hardware Confi.,'urntion 1IIId spedfy lhc directory o f the GSD file or anoth<.-, STEP 7 projcct in the w indow that appears. STE P 7 accepts the GSD lile and displays thc TO device in the hard warc e atalog und~r "PROFll'ET 10" and "Additional Field Device," , STEP 7 saves the GSO files in the directory __ IStep TlS7DATA\GSD , T he GST> flies deleted when inst3 11ing or imporling aI a later time ar" stored in the subdirectory ... \G SDlBKl'x. Fwm her~, (he y ~an b e res!Ored with OPTIONS ..... INSTAll GSO FILE. Real_t1me commllnkulion with PROl' L,' F.T PROFlNET 10 offe", several t)'f\"s of data

The IE! PEl link is able to pass on lime -of-day .elegrams and parameterizati"n data records . You can make the ,ettin&.~ for .hi s in the. propeni" , window in lhe "Optio"," lab. Configuring the IT/AS_; link You will find lhe symbol of lhc lEIAS-i link PNIO in the hardware catalog und<.-, "PROF/ NET 10". 'Gateway" and "Singk master" or "Double mast", " . Double_clicking on the lInk symbol wh~n the PROFlNP.T 10 syslem is alread y scl""ted position, lhe link at the 10 system bar.
EDIT ..... OBJECT PII.Ol'hRTIES w ith the lliIAS-i

transfer:
(>

link .,dectcd shows ill< prop"rtics w indow wjtb th" facility for setting the dev ice name and the devic" number on the Ethernet suhne!. You can change the IP addre." with tb~ .. Eth<.-'Illct ..... button.
T he lElAS-i link effectively funclio ns as the AS-;-Master. The AS -; mast<.-' ,yst"lll w itb the AS_ i slav"s is not displayed a s a subnet by the Hardware Configuration , If the lE/ AS -i link is selected. you receive th~ configuration table in which you "plug in' th~ AS-i slave, that appear it> the catalog lImier the link symhoL TI,e configuration ofth" AS_; mas\er sy'tem is described in Chapter 20.4 .2. "C onfiguring PROHBUS DP" tmder "Configu ring tho DP! AS-i link".

Non-time-critical dIlta such as configuration and diagnoSlic , information is transferred acyclicallywilh the TCP.i J? communication ;tandard. User data (inputloutput information) is ex ch ange d e)'cli~ al1y between the 10 ~ontrol ler and the 10 device (r~ al-lime RT) within a deti ned tim~ p<:riod - tb~ update time. Time-cri.iea\ user data , for II1o.ion ~"",rol applic3tioll'> for example, i, tran.< ferred with hardwa re support isochronously (ioo ehronous ,c31 t ime lRT).

t>

'>

A pcrrmmcnt commU1l1Cal!01l channel is re,erv~d on the Ethernet subnet for IRT COffilllU' nica\iol1. RT corrununic"tion - cycl ic data ex change bcn.vecn thc 10 controller a nd 10 devices - and nonreal_time TCPIlP communication take place ill parallel within the update time. In th i. way, all three conununicmion lypeS can c xist in parall cl on the s ame subnel.

20 Main Program Stnd


~yde

time/updau time

Real time Rca l time ( RT) means that a syStem processes extemal events wilhin a defined time. If il re_ sponds p~ictabIy. il is called deterministic. In RT communication. transfcr takes place 01 a SpeCIfic limc (send cycle time) Wilhill a dcfined interval (upllarc time). PROF~ET 10 allows Ihc use o f nanda. ."d IlIlN,ork components for RT communication.

Cycl ic data exchange is handled within a speci lk time frame, th e send cycle time. STEP 7 caJculal~s the send cy~le I1me from me configu ration infonnation on the PROFINET 10 systern. T'hesend cycle time is the ~hon= possible u pdate time. This is tlw tim~ p...""'Tiod widun which each 10 device in the 10 system ha~ exIlhanged it. user data with the 10 controller. 111<: actual update time for an [0 device can be a multiple o f the send cycle time. You can incrense the update lim e manually. in order to!"Cduell the hus load. for example '''Il update ti me;$ the same length focall 10 devices in me 10 system as <tlJldard. Under cerlain cin:umSlances. you can reduce the update lime f"" individual 10 devices if y{)\1 increase the lime for other devices wbose u~er data Can be eXllhanged non-lime_critlcally. You can configure the send cycle time (without IRT conununication) centrally in the Properties dial og box ofthc PN imerfaee on tbe PROF!NEr' tab, or in the Propertiel dialog box of the PROF[NET 10 sy~tel11 on the "Update time" This tab also IislS the [0 dc,ices with Ihe liPdM~ times. You can lncreas~ Ihe time for an 10 device by .dc ~ling it and clic king on the "Ed,,' hunon. or you can sel th e lime in the Properties dinlug box of the 10 de"ice On the "10 cycle" lab . In addition to tho: upda!C~ time. ~ou can j("[ the watchdog timer in thc device properties. This I~ the produci of the update limo: and the Xumber of accepled updale cycles ",ith missing 10 dala '., If Ihere is at least one synchronized d~vice in thll 10 syslem, th e send cycle time is determined by the .ync master of the sync domain and C311 only be modified in the properties of the sync domain, Select tbe [0 system in the Hardware Confii\lT8tion or thc subnet in the Nctwork Configuration, Schect EDIT ..... I'ROF INET 10 ...." DoMIUN MA ....AGnIENT. It can tben no longer be modified at another localion.

If nOI all dam to be exchanged is transferred "'i!hin the planned lime fl"'Jmc. due, for example. to the addltion o f new nem'ork ~ ompo nen's, .orne d ata i~ d istribu ted 10 o lher send frequencies . This can resu[1 in all incre3'>" in Ihe update timc for indi,.. d uaI IO devices.
Isoc hrono us rta l tltne lsocbrooous real time (IRT) il bardware-$\Ippon ed reaI_time communlC:at;on desi gned, for example. for IDOuon control applications. IRT m~~~aae frames are deterministically lransmit. led ,i3 plaoned comlllun i~at ion palhs in II 'pc<:ifie-d order. IRT communicalion therefoTC requ)reS nem'ork componcnts that suppon Ihis plaoned data trllnsmission. Isochronous real t;me 1$ avat lable in m'o ~' er sioru lhal differ in their behavior wilh regard 10 network exparn;ions. for example:
t>

"".

In the case oflRTflex ( RT Clas~ 2). the SCt1d eyelll lime is automati cally stepped down. This m ean s that the data is ,listribut ed aCrOss several send cyclc times if all the data 10 be cxchanaed is not traosferred within one send cycle time, This increases the updale nme for ind"iduallO d evices.
In the case of IRTtop (RT Clas. 3), transfer of ..11 10 data within Ihe update lime calcu. lated by the system;s iI'''' .... nleed. If the configw-acion is challaed 18ter. the update time ;3 nOI automslically adjusted. In the con. isteney ch""k. ST EP 7 draws yout attention to me fact that the update limc has to be adjusted manually.

t>

To be able to confillW"e IRT communication. set up .. IXW sync domain <lee below) and determine a sync master 10 hlllldle thc synchronized distribution of the IRT messaae frames to the sync sla, es. IRTtop requires a topoLogy configurat;On (see Topology Editor be low) and Ihus ~

'"

20 .4 Communication via Distributed TlO defined structure that takes accollnt ofthe IIan,mission properties oflhe cables and the SWilch_ es used. Syne dom a In
A sync domain is a group of PROFINET 10 nodes that exchange synchronized dala wilh each other. One node (this Can be an 10 contro lleror an 10 device) assumes the role ofthe sync mastcr, and the others are Ihe ,yoe slaves.

er a component part of th~ ,yne domain syncdo",,,in -de!all 1 r.

A sync domain can contain sevcral 10 systems, but an [0 "y,tcm is always assigned entirely to One single sync domain. Several sync domain, can cx i,t on one Ethernet subnet When an 10 system is configured. a specia l sync domain is automatically created: the synedomain -default. All configured 10 systems. 10 controllers and 10 devices are first located in \he sync domain syncdom";,,_d~!,,ull. Create a new sync domain for IR"T communication, and transfer the 10 syste m (from the $)'ncdoma;n_dej"U/I) to the ncw sync domain. Not all devices of an 10 system have 10 be synchronizcd. of in olher words. exchange data with lRT communication. \Vhen configuring. the unsynehronized nodes are first also managed in the sync domain, at runtime only the synchronized nodes remain in the sync domain. Cu nfigurlng 8 new .yne domain 1'n.-'rCquisite: You have configured the Elhernet ,ubnet with one Or more PROFThYET 10 systems. The nodes invo lved in lR"T communication must also SUp)"Klrt this function (Figure

The 10 systems Oflhe sync domain and the bus [lodes of the sel<>eled 10 system are di splayed. Now select a device, Ihen "Propen ies Device", and set the synchronization type (sync magter or sync slave) and the RT class (RT. IR"Tflex or !"TRtop) in the paramcters in the Properties w indow. Proceed appropriately with the other bus nodes . Only onc device can be the sync master, and all otber devices are sync slaves. A sync domain may comain either devices oCthe classes IR"Tflex and RT, or devices of the classes IRTlop and R"T. Sele~t the send cycle time in the "Send cycle ti m e" fie ld, and select the pro)"Klrlion o f bus communication reserved for IRT with the 'Details" h e mon . Confirm with "OK" 10 save the ,eltmgs.
Topology Editor "The "Topology Editor allows cabling eonfiguringof devices on the fndu'itrial Ethernet su bne!. The logical connections between the PROFINE"T de llices are configured with the configuring tools Hardware Configurat ion and Network Configuration , "The "Topology Editor is used to configure the physical conneClions wilh Ihc properties Le nglh and Cable type for dctermining the si gnal runtimes , Use of the "Topology Editor is a prerequisite for using IRT communicalion (isochronous real -time) . The physical eOlUleClions belween devices on the Ethernet subnel are point-to-point conn<>et;ons . "The eonne.;tions on a PN imerbce are ~al1ed portS. The Ethernet cable ~onnC<.1:i a device port with a pon On the partner devicc. To enable several nodes to commu nicate with e ach other. they are connected 10 a ,witch thai has several connections (ports) and Ihm distribute, signals. There are a lso S7 devices fealOring a PN interface thm has two or more ports sepa rated by an integral switch. With this interface you can cable communication devices in a line ar bus topology wilhout eXlernal ports. You can configure Ihe connection of two ports w ith the Hardware Configuration. In thc configuration table, select the pon and Ihen EDn ..... OBJECT PRQPF;RTlF;S. On the ""To)"Kllogy" tab i" Ihe Properties window, you can now dcter-

20,)9).
To create a new sync domain. ,elect Ihe PROF!NET 10 ,ySlem in the Hardware Configurat ion orlhe subnet;n the Network Configuralion. and select EDIT ..... PROFrNET [0 ..... DOMAIN MIINIIGIlMU-'T. "The "Domain Managcment" window that appears shows the sync domain syncdo",ain-defrwll aod all 10 systems on the same suboet that arc located in the sync domain. Create a neW sync domain with the "New" bUIton, a<sign a name, and select an 10 system wilh the "Add" bulton. lfyou wam 10 add further 10 systems, repeal the procedure. 10 systems added to the newsync domain are no long-

3I1

'-' __

rl, _iO-----c~, " .

'.1

mine .Ile p!ll'tn~..- port ~no;l cdi. the properties of the cable. A I'N inK..-face can h..,,, ~\'ernl por1~. Ifan nisting pOrt is DOl configured 8S such (does O(,)t OPp"Dr H a s ...brnodulc in the STEP 7 environ ' ment) it is referred to '" a dei""ll pori. It i. Ib"" no. di.spl .. yed in the configuration t.. ble. and any in.e~onn~etioru; are nut loaded on.o the mooule . Default portS can oniybc handled "i.h the T~~hnology Editor, Before you call .he Topology Edi .or. lIse Ihe Hardware O ,m figurdlion or the Netwo ..... Configur;l.Iinn .0 ~onfigure the communication partners on the Etherne. subDn mclU(hng the D..ceOSlll)' switches. In the Hard",,,", Conflll"ratioD. "p"n the S7 .t8lion with the 10 comrol

I..T elect Ihe PRO FlNET 10 .ys.cm and .hen . ~Iect EJ)rr ~ PROFP.-. ET 10 --+ 'TCPOWGY. ' In Ih" Ket worl< Conliaunllion . ..,It an Ethernet SUbncl and Ihen EDIT --+ PROFINET 10--+
TOI'QLOOY.

Th" wble .'Iew sho" he port pairs of all configured acti'e and passive compoDentS iD thc in.erconnections table With fihCT selling . you can dIsplay an pons. or only w inle~nnected pons. or only the nOIlinterconnected ports (figure 20 ,20) , You cnn Sel the connec li on to the partner port in the objec t proptnifl o f llle pon. You can clear <Iown aD in.enwnnlion hy ..-Iectina .he port and riah1-clid,ing on D1SCO:>'N"Ecr PORT I:-.TER_
CO"'~~CTJO.'I

312

20 .4 Communication via Distribu!ed I/O

''''- 1 -

- 1-- -1

--

... '---

- .-~ ~

Figu..., 20.20 Tabular and graphical vicw ,,1' the TopoloaY '[.d itor

If there is a conn~ction to the plant, you C8n use lhe "Onl ine" button to cbeck whcth ~r the devic eS configured oilline are available and whJt their statu~ is. Tbe comp~rison is base<l on thc d evice name, the IP address and lhc device ru . The data det.,nnine<l onlin., is displayed in the co lumns "Statu," ,md " Attenuation value".
In tb~ /o:mphic view. the topology window di,play, the devices, their ports and the int.,r<:onncctioll. The eon ftgllr<:d devices ar~ eli'played in the oftline view, and the acrnal devices a,'ail able in lhe plant arc display~-J in the online view, provid ed the", is an onli"c connection to t h~ plant.

1'0 i n!~'TC"n"cel two ports. select a port and dmg a c onnection to the partner port while holding down th (.' ri ght mouse key. You ca n disconne<..i a port by , electing the connection wilh th e right "NH:r mOllS., key and then selecting DrSCOl'v
PORl
Il,"TFllCO"N ~C TlON.

To facilitate editing, you can "dose " the rcpresentatioll uf ~he stations, hid<: the thllffihnai 1an d the ca.alog of the passive components ("Options" hutton and "Option,., tab), a"d cnla1"gc or red""e the view by .crolling wi th the m idd le mouse key.

On the Offline/ O"line comparison tab, the topology ~onfigured otl:1ine is shown alongside th" topology dCkrmin<:"d online tor compari!<On purposes. Alllhe stalions and modules are displayed ...- i\h !hcir ports. rele"ant partner port and cable dala. In this way, you can ch~'Ck the configumtioll w ith the connections and cableS. and supplement missing 'ystem compon~"ts if Tcquired. A ,election can be made with the relevam fi ller se tting, . In the overviews the d~Knnined dift" .. enccs, c.g. the module" that the Topolog y E dilor conld nOt assign, are highlighted ill color. You can now undertake manual assignment.

313

20 Main Pwgtarn 2 0.4.7 S}'ste m Blocks fo r Distribut ed lIO You c an use the following b locks in C<Jnj unction w ith the distribu ted lIO,
> FB 20 G ETIO

t>

SFC 11 DP SYN_F R Send SYNC/FREZ command s SFC 12 D- ACT - D P Activate/deactivate distributed station SFC 13 D PNRM_ DG Read diagnostics data from a DP standard .Ian, SFC 14 DPRD_ DAT Read use r data

t>

Rea d a ll input. of a station

t>

> FB 2 1 SET IO
Write to all outputs of a station
0

:>
t>

FB 22 G ET IO]A Read so me inputs of a station FB 23 SET IO PA Write to some outputs o f a stati on


SF B 75 SALRM In itiate interrupt SFC 7 DP] RAL Initiate process interrupt

SFC I S DPWR DAT


Writ~

us er data

t>

SFC 103 D P TOPOL Determine bus topology

You c an ii nd the parame ters of tlle b locks in the Table s 20.9 (FIl). 20 . I 0 (SFB) and 20 .11 (SFC).

Tab le 20.9 Function block

",,,,",,,,,,c",,,.,,,,,,,

the oii.Slti;'lI1ed L 'O

in

th~ANY

20.4 Communication via

Oi~lribu[ffi

I/O

The loada!)le function blocks FB 10 to FB 23 have interface. compliant with PNO (PROFI I'IUS lntemational) and Can be u&.,d in conjunction with 01' standard ~l avC$ l1nd 10 devices . You eRn fI"d the blockll in the Su",d"rd Library ~upplied with STEP 7 in llIe program Commll_

The d e$tination area specified with the IN , PUTS parameter must hi: e~actly the sa~ lenQ:th as th e contlgured length of the input area rend that is also output wilh the LEN par metcr. ..
FB 21 SETIO ' .... rl l., 10 aU OUlpUl S ofa statio" FB 21 SETIO uses SFC IS DPWR O AT \.0 con>1stcndy write all outpUt data or all data of an OUtput area ofa Dr standard slave or an 10 device in the ease of modular ~tation". The nallt-hand word of the ID parameter contain . the sIan address Of lhc output Hrc" to be written

nicarion Bloc/es.
You Can usc all listw system blocks with PROf"lBUS 01', me system functions SFC 12. SFC 14 RJld SFC I ~ ~rc SUItable for PR.OFINET 10. In order to read diallOostics data with pROFlNET 10, u,;c the SFB 54 RALRM . With lJPVI mode sct and DP 5]avcs ..... hieh support Ihe DPVl functionality. you can USc other syllem bloch [0 paramClenze Rnd read the diagnoone data (S<."C Chapters 11 .9.3. "Reading additional Interrupt Infonnation" al>(! 22.S. "Para~terizing Modulc$'.

w.
The source area specified with the OlITPUTS parameter mUSI be exactly the same lengl~ all me ~onfigure<l length or the OUtpul area to be wnnen 10. This is why infonnat;on in the LION parameter is im::k"ant. FH 22 GETIO pA Read ~Om~ Input. of a .Iallon FB 21 GEnO~PA usc. SFC HI UBLKM OV to consiSM1I\Y read some or the input data or SOIne of the data of an inpul area of a DP mlDdud slave or an 10 dcvice in thc c~ ofmodular $tal;onS. The righI_hand word o f the ID pa-

t' 8 20

G~:TIO

Read _II Inputs of a 11>I1Ion FB 10 G ETIO USeS SFC 14 DPRD OAT to eomistemly read all input dRtB ofa DP standard slave or an 10 device or.lI dala of an input area in the c ase of modular S,,"lions. The right_hand word orlbe ID parameter contains me tan addrc:lS of the input ~8 \.0 be read.
T.hl~

10.10

Par.tm~'"

Mtlle SFB 75 SALRM

'T~II>I<

lO.t1 P eers aram t

fDl" SFC.

U..,d R 'he n;Jtribu,~d LO~~~~~========= efcrrnce


to

.,
,,

.,

,.
rqIC.,....
r

'"

rameter contains thl: start addrus "f the inpUt

S FB ?S SAt.R."

area. the OFF SET parametC'f contain$ the number of tbe first byte to be read , lIOd the LEN parametcrcontainsthe nUIl'1bcr of byte,
The input bytes In be read m"-~I be addrcsSw. in the pro<:e$s image of lhe input in order 10 usc the FB 22 GETlO_PA. Ifpossib1c. it is prtfmt ble 10 usc a partial process image. Plea~ CTlsure that the OFFSET lUld LEN paramclcn do nol violate any bound~ries with n~illhboring d~ta of otber ~lations.

InItial(! l !lt~rr u~t


With SFB 7S SALR.M. you ,n;tiale. diagnostic intcnupl or procc-s. inlerrupt in the or masle-r .lioeiated with an ;ntellil!~nt slnve from the USI:r program of that slave. Vou deline the type ofintemJPI U5in~ the ATYPE parameter. The interrupt requeSI is initiated wilh REQ "1", the DONE, BUSV. ERROR and STATUS

Irtbe de~tinallon ana !!pCCified by 1M INPUTS parameter i. smDlIer than tbe input are~ ~ad. the fu"ctiononly transfers a, many bytes as can be "'TitleD to the d~SlinatiOD ar\:a. Ifthe destination arca is IUllcr, only the fi""t LE:>' hies of the .rea are wrinen to. In bOlb cases, no error is indicated on tbe F.RROR pnl"ll.metn ERROR "nly ha~ signal 51ate .. ," if an error i< TCp<lrted whcn calling SFC SI BLKMOV
FB l J SETIO]A Wrtl~ so me o ut pu ts to . J1 al lo u

par" rneters indicate the job statuS. The job is complete (BUSY - 'O) ....ben Ihe interrupt OB ill IlK DP m.a~tc:-r bas bceo e"calted.
The transfer mem"ry between the DP master and tilt- intelli&ent DP slb,e can be divided into llldi"dual address llTCas that represent individ_ ual modules from the viewpoint of the maSter CPO. Yoo can initiate an imenupl;n the ma~ler for each of these addr~S9 areas ("""irmaI" mooules). Vou specify the address area with the ID pardmetcr which you o<:cupy ",ilh a u...- data address from the viewpoint of the sl ave C I'U. Bit 15 contains the 110 identificut i",,: "0" corre'ponds 10 an input address. "I" to an OOtput address. The Man mformation of the intenupt OB then OOtItains the IMkIresses of the module'" initintinll Ihe interrupt fr<)!\1lhe viewpOint ufthe rnm,tet CPU.

FB 23 ScIlO]A uscsSFC gl UBLKMOV 10 consi~t~!\!ly write sOme of the Output data of an output area of a OP st.andard slave or an 10 <leviceor some oflhe data of an uutput area in the ca~ of modular slations. The right_hand word oflhe to paramelercontains the start addr"~ of the "1I1p"t a....,a. the OFFSET parameter contains the oumber of the Ii""t byte to be written, and the L8" paramet...- COIItains the num~ of bytes, The Olltput byt~' to be wriucn must be ad_ dr<oss<--d in the proce.. image of the outpUt in Ofder 10 uSC the FB 23 SETIO_I'A. If possible. it i~ p~f.-rable to USe a partial proc"~ i ma~e. Please enSlll"e that the OFFSET and LE!-< ps_ rametcn do not violate any boundarie; with neighboring mota ur otl\.er stltiOfu. If tl\.e SDuJ'l:e Bru specified by me OUTPUTS parameler is smaller than tbe Output =~ 10 be written. the function only tran.fer. as many bytes 15 the source...-ea comaiDs. If the source arca is larger. only the first LJ.N b}1eS """ tran5_ fem:d. In both cases. "" error is indicated 00 'he ERROR parame!"". ERROR only has ~ignal stale "I" if an errw i~ rep<lrtw when calling SFC gl BLKMOV.

Use the AI\lfO paramel<:T to \J1Inlfcr supplementary interrupt information which you ha,'e Ii( fined and which caD b<: evalnaled in the interNp! 09 of the master CPU. The reference to Ai'-l'O i, Il.~an A/'."Y poi-ntertoa data arcll. The length orlhe sent informalion is defined by the LEN p"'lImcter and by the area lenllth nf the AXY poimer (the shorter length i~ de<:i~ive). The first 4 bytcs ~ displ.yed in the start information of the interrupt OB in the ma~tC'f CPU in byte,; ~ to II (the vatiabk OHxx_POr~T_ ADDR for process interrupts, lhe data record DS 0 r"r the dillgno5lic imerrupt). The complete supplementary interrupt infonnation ClIn be read in the master CPU using SF IJ S4 RALRM. S f C 7 DP _PRAL Ini tiat e a prucc.. ln ttrrupt With SFC 7 OP_PRAL. you initiate a pro<.:eu inrerrupl in tbe OP rna",r associated with an

20 Main Program intelligent slave from the ">SCI" program oflhat slave. At the paNimeter AL_INFO you transfcr Bn interrupl 10 defined by you that tS traIlsfeITed to the Slart information of the int~rrupt OB called in the 01' master (variable OB",,_pOI}/T_ AOO R). The imenup. request is initia.ed with REQ _ "I"; .he paramcll;~ RET VAL lind BUS Y indica ., the job status. The job is complete whe n the interrupl 08 in the OP mllstcr has been e xe.:uted. The transfer memory heTween the DI' master
and the intelligent 01' sl.,e can he di\"ided intO indi\"id ual add...,ss areas that represem individual modu les from the vie ...."J>Oim of the master CI'U. The lowes t address of an address """a is

In this w.). SYNC mode and F REEZE mode On !he OP slaves are rUSt switched off. The inputs of the DP slaves an. scanned in $CqUence by the OP master and the outputs of tbe O P slave! are modified: tbe DP .bves pa.. the receive<! output signals immediatciy \0 the outputtenoinals. If you Want to ""free~e" the input signals of se\"eral DP slaves at a specific time, you output tbe command fREEZ E to the r~levant group . The input siana!.s then read in sc-quence by the DP master have the sianal states they bad when frozen'. These input signals ""Iain their value until you OUtput another FREEZE command to cause the DP slaves to read in and hold tbe current input signals, OT until you switch the OP daves back to the "nonna]"" mode with the UNFREEZE command. If you want to outpUt tbe output sianals of K " el1l1 DP sluves ")"Dcbronously at. s~cific time. lust Output the SYK"C command to the ...,levant group. n,C addreued OP slaves then hold the current signals at the output terminals. Now you can u-ansfer t~ desired signal statt'S to the DP sla'cs. Fonm.in~ th U1Ulsfc-r. you output the SYNC eommand I,ain; thi.'< cauRS the O P sJa,'cs to switch the receIved outpUt signals sin\\I\taoeously through to the outpul Ic n ninals. The accessed OP slaVe! then hold the signals at .he outpUt telIDmal. until you switch through the ncw output signals " ..ith a neW SYNC 00I!1mand. 01" until you switcb the OP sllves back m meLr "normal" mode with the UNSY"NC command.

taken R~ Ihe mooule starting a ddre ... You can inili ate a process intemlpt in the maSter for each of thesc address arell$ (""virtua.l"" modules). You specify an address ~a at SFC 7 with tbe parameters 1010 and LAO DR from the v,ew_ point o f the slave CPU (the UO ID and the Startmg address of the slave side). The stan information of the imerrupt 08 then contains the addresJCS of the ""module" jnitiatina the imerrupl from the viewpomt of me master CPt:.

~nd

SfC 11 DfSYN_ FR Sy;o;C/t""REEZE comm a nd. With SFC 11 DPSYN_FR, you srnd the commands SYNC, UNSYNC, FREEZE and UNF REEZE to a SYNC/fREEZE i'OOp that yOll have configllred with the Hardwa~ Configuration. The SE!'-.'D is initiated wim REQ " I " and i$ completed when BUSY - '-0- is signaled, In the paramet ~r GROUP ncb group occupies one bi t (fro m bit 0 - group I to b it 7 -afOUp 8). Tbe commands in the parameter MODE are also organized by bit:
<> UNFREEZE. ifbi! 2 - "I"
t> t>
t>

S FC 12 D_ACT_ DP Act h 'a tud ea ct! \"Ile d lstrlbut.. d UlOlLo n


SfC 11 O_ACT_DP deacli'll.tes and activates ~talions o f the distributed UO and allow. sc anning of the deactivated or activated StatuS. A distributed station can be a OP sl,,'e or an 10 device. SFC 12 0 _ACT_ DP;I called in the cyclic prognl1n: callin g in the !"estLUt TOutme is not suppnMcd. The SFC operateS in asyn~hronous mode. i.e. processina of a job can ext~Dd over sC\eral program cycles. A "1'" at tbe REQ parameter stlllU an acttvation or duCti~1ItiOD job. As loug as the B1.:SY pammeter is '"I", ,be

FR EEZE, if b it 3 - 'T'

UNSYNC,ifbit4-"\"
SYNC, ifbiI5 - ~I"

In th is manner you can use just one call to .send 5e veral commands c,'en to Kveral groups.

20.4 Communicatioo via o;.lributed ItO

REQ
~en

par~mCler must remain 'T', The job bas finished if BUSY - "0".

ferred and th. relC'.ant ove.t10w bit iltheo set


in the data.

After deactivation. ~ confii/ured (and exi.tin!':) station is no longcr addrened by the DP master or the 10 controller. The output terminals of dcactivat~"<i outpul module$ callY Of a substitute yalue. The process i.mag< of the input> of de,Clh"Dted input modules i, SCI 10 .-o~.

The parameter RECORD wriles to the area in ",hich th. read dala are stor.d, Variables of dala lype ARRAY and STRUCT or an AXY pointer of datil type B'YTE (e.g. PI:'DBzl)... BXy.xBYTEnnn) are permissible lIS actual panmetcn.
Plea.e note !lUll the SFC 13 OPMRI\CDG i. an a.ynch.ronou. syslem functi(m. It must be proceilsed unlll the BUSY parameter liillal.. the ,Iatu. '-0". The SFS 54 RALRM is avai lable with lW'wer CPCs whi ch providel the data in synchronous mode. i.e, inunediRtdy following the call.

A dCHcthlited .lave can be: lIlken otT th~ bus


without an error mC'SSage: h ""ill not ~ reported as faulty or mis:>;ng. C a lls of tile asynchronous error organization blocks OB 85 (program exe_ cution error.;, when the u~c.,. data of the d~aC1i vated slave IITC located in an automatically updated process image) and 08 86 (stanon failUfe) ..sc. After deacnv,tion, you must no longer .~e .. the DP ,I","e from the program, sin<:c direct access will lead to an LO access =or with e,lIing of the OB 122 or. when reading a dutllwcoro with SFC 59 RD _REC or SFB 52 RDREC, the OP slave,. S!iIlaled !U being non,existent. With SfC 11 D_ACT_DP. ~'ou reac tivate a deactivatw OP slave. The DP slave is configured and pammeierized by the DP mllSlC'I"Of 10 controller in the same way as during .. slatioo l'CitoU.. On :octi"nion. the .syncbronou. error OBs 85 llIld 86 are nOi ~ed, [fthe panunelC1" BUSY"" ",gnal Slale '-0.' follo"'inl! '~ti\lI_ lion. the OP ~Ia,e can be accened from the user progrum. With a cold restan or wano reSl~n. the CPU', opetllling sySlem automatically ICti,'ales the deactivated DP slave. An S7-300-C PU waits with stan up until all nalions.u. acti'~lcd. An S7-400 CPU starl!i up and repons I/O ac~cu errors until the stations ltave been &i'lIIO<!. Wil\! a bot restart. the: DP slave stalUs is retainO<!. SFC 13 DPI\IR:\! DC Read dlagno. tlc data
SFC 13 DP),IRM_DG read~ diagnostk data from Ii OP slave. The u.ad procectuu. is inilialed with REQ - "I". and is tel1llioaled ... hen BUSY ~ '-0.' is returned. Fuoction Hlue RET_VAL

S FC 14 DPR D_DAT Read use r dala SFC 14 DPRD _OAT reads consistent u_ dala with a le1li1h of 3 bytes or greater titan 4 byteS from a DP slav~ or an 10 devicc. You specify the l~ni!h of th. data consistency when ),ou pa1'1lmeterize Ih. 'Iation,
Th~

panlmeler LADDR contains tbe module

itarring address of the user data (input area) .


The paraaN:ltt RECORD "'Tltes to the area in "hich the =d data arc ,~, Variables of data type ARRAY and STRUCT or an AI'Y poinleT of data type BYTE are permissible as actual parameters (e.j:. P>10BzOnXy.xBYTEnnn).

SFC IS OP\VR_DAT
\\'rll",
u~r

dala

SFC 15 DPWR_OAT ",riICS COD3ist~""1 user data with. Itflgth of .3 bytes or j:ft"alCr than 4 bytes to a DP sla\"t oran 10 devi<;c. You specify the lenath of the data consisICncy whm you panmetenze the station.

Th. panuneter LADDR comaills the modul e ~taning add~ss of the uscr data (outpul area).

The parameter RECORD writes to the area in


""hlcb the u.ad data are 'Iored. Vllriabln of data type ARRAY and STRUCT or an ANY pointer

tben cOlltains the number of bytes read. OI:po:ndi"il on the alave, diBl,'nO$tiC data m.1.y compti.e from 6 10 240 byte . Iftheu. are lDOfe than 240 bytcs, the I1nt 240 b~'es are tr1UlS-

of dall type BYTE are perrni$Sible lIS acOlal parameters (e.g. f'liDBzDBXy.lIBYTEnnn). If pmpheral OUtput. (PQ) arc addresocd ""hose addresses a~ in the process imalle of the oulputs (rIQ), the process image is tracked as with

20 Main Program

the transfer instruction (STL) or the MOVE box (LAD, fBD),


SFC 103 DP _TOPOL Determine bus topology SfC 103 DP_TOPOL uses diagnostics r~pc" t erg 10 determin e Ihe bus lopo logy of the P I' ma'l~r system whm ~ ID you spec ify in the D P_ TO panuneter. Octenninalion IS tri ggered by REQ - "1" and has beeu comp lelM when B U SY - "0". You can abort dcte mtination of the topology usin g R - " 1'".
If an CITor wh'ch prevents d et Mminati on orlne

After cailmg lhe SFC 103 OP _TOPO L, the det.tmmed data are ava ilab le on the diagnostics rcpealer and Can be read with !he SFC 59 RD REC or SFB 52 RDREC. The data compris~ the IOpology of the bu s , egment (nodes and c able lengths), the contents of the segment diagnoslic' b UITer (last ten events w ith error in fonnat ion , location and cause) and Ihe ,ta lis_ tics data (information on ' he quality o f the bu, sy stem)

20.5 Gl obal Data Comm unication


20.5,1 Fundamentals
Global data communication (GO communi cation) i, a co mmunications s t t'\i cc integrated ioto Ihe operating system of the CPU and used for exchanging small volumes ofnon-time-eritkal dala via the MPJ bus. The lnIn, ferab l" glo bal data include
t> t> t>

bu.. topology is signaled b y a diagnostics repealer. it is a shown in the D PR aIld OrRl parameters. If se ve ral diagnostics repeater:;; sig_ na! errors, the error message n f lhe fma oue is displayed. and the complete di agnOSlk s infor_ mation can be read with SFC 13 D PN R.\1 DG The e rror infonnation in the D PR! parameter i;; differentiated between lemponuy and p " =ncnl faults. Temporary fau lts . such as a 100,,, contact, may b c difficult to identify and m ay disappear nn th eir own. You must climir.a,,, permanent faults before you "a li lhe SFC 103 OP_TOPOL a gain to detcnnmc the topo logy.

Input. and outputs (proc ess im ages)

Memory hilS
Data in data blocks
,~nt.

> Timer aod coun ter values a s data to be

5tMATIC 51.t8lioo Glbal data table

u.."

prog'''''' i~ ..... CP1J


~ ra t l "," u .~,

:. FI : I
..,""'m trarlr..fS

,eo

--"""'.,"

5tMATtC 51 st.atlon

oe"

':;;::,.' _._." : I tI
Cydl~ :

GloOooI

<I.'. tab<o

CycIU: "...

n,. o.,.",tinQ . y...m "'001.<$


Pf'O\Iram

tI>e <1<1'" ,.,.Ithoot 8

PfOI1f3rt'1

do", ",1U""" U_

j
in

.. .. =

.,.

ev"", trill'P _ ' T,IO!lm., ,.,."" S FC _


\IS<t<" ~O\j,am

:J
Subn

-:j
60161

.. l
-""
_ $," 11"_

.,.

.lo----j

..

..

Ftgvn lO.21 Global Data Com,mmica,ion

20 .5 Global Data
It is a requirement that the CPUs atc networked

Comm uni~alion

GO drcl e

wgether via the MPI interface or connected via th e K bus as in the 57-400 mouDling rack. All CPUs roust ex;st ;n tbe Same STEP 7 project in order 10 "" able to configure GD comrnUIlica lion. The cyclic GD communication ;;ervice does not rcqui,.., an op~raling ~ystem : there are system functions avaibble for e,'ent-dri"cn GD communication on the 57-400. Please nole that a receiver CPU does not acknowledge ,..,ceip! of global data. The sender the,..,fore docs not receive any ",spons~ to tdl it if a recei"cr has received data and if so. which one . However. you Can screen the communication status between two CPCs "' well as Ihe overall status of all GO circles ofa CPU. Sending and ,..,ceiving global data is controlled with what arc known as scan rates. The,. specify the num""r of (user program) cycles after which thc CPU sends or receives the data. Sending and receiving takes place synchronously betwe<cn the sender and the receiver at the cycle conllo1 point in each casco i.e. following cyclic program e"ccution and ""fore a new program cycle begins (like process image updating. fOf c"ample). Data is e"changed in the form of data packets (GO packetS) between CPU. grouped into GO cirde"

The CPUs that ."change a shared GO packet form a GO circlc. A GO circlc can"" any of the following
:>

The one-way connection o f a CPU that scnds a GO packet to several other CPUs that tben receive that packet.

[>

The two-way cotulcction bem'cen two CPUs wbere each oflhe two CPUs can send a GO packet 10 the other. The f'xo_way connection between three CPUs where each of the three CPUs can send one GO packet to the other m'o CPUs (S7-400 CPUs only).

[>

Up to l~ CPUs can exchange data with each other in one GD circle. One CPU can also beloog 10 several GD ~irc1es. See Table 20.12 for the resources of each ind ividual CPU here.

GD packet
A GO packet comprises Ihe pach1 hca<k-r and one ot more gl obal data elements (GD elements):
[>

:>
[>

:>
[>

:>

Packel header (8 bytes) ID of I"GD element (2 bytes) User data of I" GO clement (x bytes) ID of2 nd GD clement (2 bytes) User data 0[2 00 GD element (x bytes) etc .

Each GD element consists of2 bytes of de scription and the a ctual net data. 3 bytes are required

Table 20. t 2 CPU Resource, for Global Data COIIlmun;ca"on


CPU 312 CPU 313

CPU 31-1

20 Mllin Program
in the GD packet \0 tran8f~r B m~mory byte. 4 bytes B' requi,d for B memory word, and 6 bytes for a memory doubleword . A Boolean variable o<oeupi~s I byte of net dala; it therefo~ rcqui,s the same space as a byte+sized "arlttble. Timer and counter valuei wltb 2 bytcs eacb occupy 4 bytes each in the GD packet. A G O clement can .lso be an address arca. MB 0:15, fo r example. rt'Jlrellents the a,a from memo ry byte MB 0 to MB 15, and D B20.DBW I4:8 represents the data area located in DB 20 lbat .tart!! from data word DIlW 14 and comprises 8 data words. The maximum .ize o f a G O packet is 32 byte~ on lite S7-300 and 64 bytes on the S7-400. TI:.r maximum nwnbcr of net data byte, per packet is reacbed with tlte transfer of on 1)' one GO element that cODlaifl!l up to 22 bytes on the S7-300 and up 10 54 byte!! on the S7-400. Oat.
con.j.t~ncy

the 'levant length are formed, starting "ith the first byte.
lO.!'i.2 CO llfi gurini GO CO OlmuniutiOIl

Requi rement. You must bave created a project. th".,.., must M /I.I PI subneM'ork IVlilable and you must ha~e configured the S7 st,tiOttll. The CPu. Bt least. must be a vailable in the stations. Under the "l'Topertie," b ulton of the MPI interface. on the "General"' tab of the properties window of t~e CPU (double-di ck on th e CPU line in the Hardware Configuration or o n the line Wilh the MPI interface submodul c), you can ,et the MP[ Id<ln:$, and select the MP[ subnetwork with which rhe CPU is COlIDected.
811

Gl obal da t. tlIble
You configure G O cOlDmUllicatioll by tillillK ou t a table. With the icon for the MPI subnct"W ork scl~ ct~d in thc SIM AT! C Manager or in t~e Network Conflgurotlon. you can call up an emplY table witb OPT10-';S ...... DEFL'lE GLOBAL OATA. Select the 51allon in the left half of tbc project selcctioll window that rhen opens. alld

Tile data consistenc y covers one GO elem ent. If a GO clement overwrites a C PU-specific vari able, the areas specified in Table 20.12 apply l f a GO clement is grelter than the length oftbe dat. cOllsistcncy, blocks with consistent data of

i .. ' ~----------- Up

to 15 CPU," ------------,~

."
GO circle 1
GO circle 2

Hp&Wlll , ,
, , , ,

Hp"cke!l ~

"
p,"ek6t ' I ..

,
~' i

~pacl<.t 2H
H

GO cirdo 3

'.

i.

Ipacket3H

GO cItde 4

Hp~tr-:

, ,

"'Ku re 10.12 Example ofOD C;n; leo

l O.S Global nala Communicalion

CPU in Ihe righl half. This CPU is Ilcccpled imo the g lobal data tDble with OK. in exactly the same way with the other panicipaling in GD corntn ...nkation. A global duta table can contain up to I S CPU colCPU~ PrO<.:~~d

scl~el Ih~

GO 10

umM.
To config ......., data transfer octwecn CPUs. scl~cI llIe first line under Ibe send CPU and sp<:<.:i fy the add",,!! .... hose value is to be tranSfcm:d (terminate wllh RETUR:,"). Wilh EDrr --lo SE:-.IDER., you dcflTc Ihis value as Ihe value to he .~nt. indicated by a p-rcfixed cllaracler ..",. and sh<1ding. In tbe .arne line under ite<:eiverCPU, you enler Ihe.t~ thai is 10 accept th'" value (the propcny M itecei"",'" is sel as <kfauh). You 1IlII)' 115., timer and coumer (unclions ooly as sen<.krs; !he ""eelver ml1St be an add""'. o f word wtdth fo.-ueh timer or counter function.

fQllowing error-free compiling, ST EP 7 completes the "G D I D" ~Qlumn. The GO ID shows you bo" Ihc transferred dOli arc strucrured into GO circles. GO ,,""ckets and GO clem,'nts. For example. the GO ro "GO 2.1.3" carrcsponds '0 GO cir<:le 2. GO packet 1. GO clemcnt 3. You c;[.ll; llIen find the rcsourc~ assiaruDenl (num""" of ( ;0 cireles) per CPU;n the CPU column of the global data table.

GO stat u)
compiling. you can enter the for the communication ~talU. into the global data table with VIEw ..... GO STATUS. The o,en.U stalUs (GST) shows Ihc .tatu.~ of all conununicatioIL> COIDlC<'tions in Ibe table. The !talUS (GDS) shows the St:alu~ ofa communications connection (a mm~milled G O packet). The ,latus is shown in a dcubleword ;n each

Follo" i" a
addl"C'~"'s

~ a se.

A line Can contain several r:ei" cr< but only one sender (Tablc 20.13). After filling Ihi' in. you select GO TAilU --lo CO~lPn.L .-. ner compi ling (phase I J, Ihe system data cn:ated are suffieienl for global data communication. If you also configure the GO Status (Ihe . tallU o fthc GD connecl;e>n) nnd thc scan rates, you must then compile the GD tDble for a ,ec_ ond lime .

SCln fMC,

The GD eomrnunicalion Krvice ....,qu i",s a significant ponion of execu tion I;me in the C PU opC1"Bting .y"em and demands transm,ssion lime on the MPI bus. To keep this "communica\;OII!IIOIId" 10 a minimum, if is ]IOIIsible to <peeifY I "SCaD ,,!.tc. A &can rate specifies the nul1\ber of pt"Oaram cycle" after which the data (or mQl"~ pre<: i~e1y. a GO pack\<t) are 10 be scnl or received.

Table l O.13 J:;urople of a GO Tobie ..1m Status .nd S"", R.,."

323

20 Main Propm S incc !he d aLa are DOl updated in ." cry pTQjp1UI1 cyd c Wilh a ,c;:an rat~, you ~houLd a~'oid ,ending time-c;:ri(ic;:al data via this form of~ommuni cPtion. A fler the fir~t (error-frce) compilation. you elln use V IUW ..... SCAN RA TFS (0 define Ihe scali fIIles (SR.) yourse lf for each (iD packel and each CPU. The scan r~t<: is set as .Iandard in such a way that with an "emp ly" CPU (110 user p rogram) the 01) packets are sent and r<;<;eived approJl:imalclyevcry 10 m...lfa user program is then loaded. the time interval increases.

20.S.3 System F.. .. ct loIlJ ror GD Communicatio ..


In 57 -400 S)St~-m5. you can al$O eontrol G D

commuoication in you r proanun. Ad ditionally o r alternatively 10 the ,yclic tran~fer o f global data, you Can se nd 01" receive a GO r ac ket wi lh the following SFC s:
t>

S FC 60 GD_SNO Send GO packet SFC 61 GO RCV Re<:eiYe GO pac ket

t>

Yo u <;Qn elUer the can rates in the area between I IltId 25S. !'Iease oote. that as Ihe scan mIn d ecreasc. the oommunicalions load On the C !'U in<;rea~. To keep the communications load with in tolerable limits. SCt the scan ..... te in the send C !'U in such a waythallhe product of scan nlle !lnd cycle time on Ihe S1-3OO is jOruterthan 60 ms K vn thc S1-400 grealer than 10 tnl. In nd the receive CPU. thi.~ prod""t m ust be les~ than tb l'l in the 5end CP U to avoid the los! of nlly ( llJ radets.
Wilh scan rate O. you ~witch off data ellchpnllc OrlM rel<:vant GD packet if yo" only want to " .",)(] Of" rcccivc it evenl-driven with SFCs. AlleT eonfigurini the GO .ta~ tmd the ""an t"8lCS. you must compile thc GO table for a seco nd time. Then STEP 1 enters the compIled <.bla in theSystctn data object. GO cornmllDie~ tion becom Cl< e ffective wh~"I\ you lran ~fcr the: GD table to the coone<:ted CPU. wilh PLC -+
noWl'1.0AlJ TO '-10l.llJLIO.

The paramete", for th~~ S FCs are li~ted in Tahle 20.14. The pn:~uisite for the usc o f the.e SFCs i5 a con fi~ured global data table. After compiling Ihi~ tPble, STEP 7 ~ho"" you.. in 'he '"Gn identifier" coluntll. the numbers o f Ihe GO cirele, and Gn P'lckets " 'hk h you need fOT panun<;ler a",i8mn~Dts. SFC 60 GD_S:-m COler! Ih c GD p~ckcI ; n tbc $ygt~m m emory of Ihe CPU Bnd initi"te~ tranSfer; SFC 61 GO_ReV felc hes the GO packet from tbe system memory. Ir .. Ij<;lIn rate greater than 0 has b~cn specified for the GO packet in the GD table . cyclic trarufer MI"" tllkcs placc.

If you wanlta eusuTe data consistency for the entire G D packet when tnilnsft:ning wim SFCs 60 and 61 you must disable or delay higher_pri_ ority intCTIUpt, and asynchronouJ erro,.,. o n both the Send and Receive side during processing of SFC 60 o r SFC 6( .
The SfCs n.~d not be called in pair,: "m illed" oper"tion is &"" po,s ible. f or e ~~mp1c. y'm c an 1 Uje SfC 60 GD_SND 10 have cvent-dri "cn lrIIllsmisston of GO packet s but tben receive cyclically.

00 commtmi calion a lso becom~s eft\~live when Ih e Sy#em Jaw obj~cl . t:hat contain s Kit hardware ~ellin85 and par~meter setl"I&~. i~ tralllferred.

324

20, 6 S7 Basic Comm uni~at;on

20.6 S7 Basic Communication


20.6.1 Station- i oternal S7 Ba,ie C OO"" u" i ca thm
Fundamental.
\Vi~h 8tati o,, int~mal S7 bas ic communication. you can exchange data bClVI"ecn programmable modules with in a SrMAllC station, The eomm unication. fu nctions requir~d her~ nr~ SFCs in the o!><,rating 'yst~m of me CP U. Thes~ S FC < eslablish the commwl ication connection<; them_ sdve<. if n""""ary. For this reason, these sla' tion-internal connec tions are nO! <:l>nfigun:d , in the ~Ot1n""lion table (, 'CommWlication via 000 oonfigurffi OOllllCC"liOru, ', SFC communication),

ing comp letion of the j ob (pwgro", mable) , If a co" nc.:tion buildup CStl1\ot be executed due!o lack o f resom'ces e ith er in the ,ending device or in tk r~""ci vin gc dcvi <:(.' . "Temporal')' lack of rcsourc ~ s"' is , isna]ed. T ron <fe r m u, t t~ cn be reinitiate<:l. There can only be onC conn""ti on bet"'cen two corrununi<:ation partners in ~ach direc tion ,

Yo u can use one syst ~m fun ctiun for different communication eonnec ti(ln' by modifying: the block r arameters at runtime. An SFC cannot interrupt it,d. A program ,celion in which on~ of (h cs~ SFC. is " <;e<.\ can on ly be modified in the STOP moM: following this. a cold or wa,m restan m " ' tthcn be exccutc<.\ ,
U s~r

dNta . duta consistenc),

Station-internal S 7 bH ic comm un ication can tak~ p lace. fo r ~ "arnpl e, pamll~ 110 cy clic data exchange via PKOI' I I>U S IW between the rn ft,tCT C PU and the slave CPU, w ith data transfer being evenHiri \ '~n (F ig\l rc 20 .23). A ddre ..inl:
tb~

nod,-. <onntio n,

Nodc identification is deri,,~d from the L O addrc8<: at the L AD DR parameter, you 5!><,cify the moduk , tar\ing addre ss and at !.h~ IOID param eter, you s!><,cify wh~ther thi, add,~ s> is in the input ar ea or the output area . Th ese system functioru; ~ slablish the n~ c essal')' corrununication conncctions dynamically and they clear the <:ullllc<:tiuns down ag~ i n follow-

These SFC , , ran8fcr u p to 76 byte, as \lSer data . Re~ardlc >s ofthe direction oClran . fer. the op<:ratiJ:lg sysl"m of a CP U arranges the u ser data in b l<xks that are consi, tenl within thcm8e1ves. The length of cOllsistent tran "f~-rred data i. a C PU -,peci fic , an ab le. If two CPU, exchange data. tile block size of the "'passive"' CPU is d ecisive fo r dam coru; i,tcn~y, C onll l;::u d n g st ation-infernal S7 b :ts!c communicatlon Sta tion-internal S 7 ba sic cornmuni callon is a sp ccial ~a,c ;n !.h at it n:qui res no con ljguring ,;nce data tra nsf~r i< handled via d ynamic connection<, You 8i mply w;~ an ~x i sting T'R O F1 _

51MATIC 57 .1alion
u .....
~

51MATIC 57 slillo n
M"d'.l~~

in ll><t CPU

On .. w~y C1>nrMc'i<>n: In \he ~ _ . fnm' fo, is with SFC C<II I in u,"" p<09<~ m

O_ w~y

.,.",.,..,Uon:

In II",

~ ng

.,

'ys"' ~

>tatic<\. the "P<""t;,.. f1otohoo. 0' write. """ d ota

.:J
325

Fi~u""

20.23

St a'ion - l n ' ~TIlal

S7 Basic Cmnmu:::ica<ioo

20 Main Program
Tobie 20. 1~ SFC PanMC,e" for Slati<m_ln1<.>rnaJ S7 Ha.ic Communica1ion

,.

aus .ubnerworJ,; or you ereale one either in Ihc S IMATIC Manager (select thc Project objcct and then INSERT -4 SUfI'llTWORK ...... PROF!BUS) or in the Nctwo,\': Configuration (see Chapter 2.4, ''Configuring the Nemork").
Rumple: you have confil!:urcd distributed \;0 with a CPU JI52[)P as maSter. Vou usc anotheeCrU 31 S-2DP as an "iotelligeot- sl.,e. You can now use station-inlemal S7 basic com mun ication from both controllers to read ""d write data. 20.6.2 System F u nctIons fo r Shll ion . [ntcr. nal S7 Ba~lc Co m m unicatIon The following sy~ICnt funclions handle data transfers between two CPL"s in the .ame Sill tion:

BUS Y is set to '"j Changes to Ihe REO panunctcr no longC!" have any e!fccl. When Ihe job is completed, BUSY is reset to '0". tfREQ is still "1 "", the job is immedi"tely resta rted .

When the read procedure has bc<:n initialed, the o)Wrating system in Ihc panner CPU assembles and .eods !he requested data. An SFC cnll moosfers the Recc"'e dalll to the destinal ioo area. RET_ VAL then ihows the number of bytes transferred.

If CONT ;s .. 0. thc conmtuoicalion link is broken . If CONT is .. ''1'', the link is mn ;n tained. The data are al$O r~ad whcn the comm u nication paroler is in STor mode.
lbe RD and VAR_ADDR parameters describe Ihe area from which the dalll to be ltallsferred 11K to be r.."d or to which the receive daJa are 10 be wrinen. Actual pIIrllmeters may b<: addresses. ,-ariahles Or dalD &",a5 add,..,s~ed wi,h an Ar-'Y pointer. The Send and Reccive data arc not checked for iden tica l data types. SfC 73 I PUT ' ''dte d a ta

S FC 72 I_GET Read data SFC 73 I PUT Write datn SFC 74 I_ABORT Di.connecl

The parameters for thcse SFCi arc listed in Table 20.15.

s.c n

t _G ET Itu.d data

A job is initiated wilh REQ " "1- and BUSY " "0" (Ii,.;t call"). While Ihe job is in progress.

A job is inlli&lcd with REQ - "I and BUSY.'O~ (first cal!""). While Ihe job is in progres. nUSY is ,et to .'\-. Ch:mllcS to the REQ parameter no IoniC, ha"e any effect. Whim Ihe job i.completcd, BUSY il reset to .'0". IfREQ is still T'. the job is immediately reslancd.

326

20.6 57 aask Communication

When tbe write rro.:edu~ hu been initiated. Ihe opcnoting system transrcTS.lI data from the

ZO.6.) St.tlon-Exteroal S1 Basic Cornmunleatlnn


Fundal1l~otal.

source area to an internal bulTer on the first call,


and sends them to the partner in tbe link. Thett, the receiver writes the data intO) data area VAR ADDR. BUSY i. then set to ''0'', The data ~ also ....T1nen "ben the receiVing panner is 11.1 STOP. The SD and VAR_AODR paramete", descriM the ana from which lb. dala Ln be transferred are 10 be read arlo whIch the =l'ive data are \0 be ",rinen. Actual paramelus may be OOdreS'el. variables or data are .... addressed with an ANY pointer. The Send and Rcw;,"e dati are not checl<~ for identIcal data types.

\\"iib station-external S7 basic communication, )"011 ean ha,c event-dri,en data excbange between SUtotATIC S7 stations. The staliol1'l mU5t be =ttted to each other vi. an MPI rubDe:\<o"OR:. The communications functions reqllired for thi, SF Cs in the operating system orthe CPU. These SFC, establish the communication eonne<:l ions themselves, if nessary. For this reason, these station,ex ternal coonections are nOl coofigllrW via the conn<>etion table ("'Communication ,il non-configured connections'").

S FC 74 CABORT DiJcanno:'C t
RI;:Q _ " I" breaks II. connection 10 the specified commun ication parmer. With l_ABORT. you can break only Ihos.e connec:tions u lablisbed in th~ lime nation with I_GET or I PUT. thejob is inp~,. BUSY is ~~t to ~I. Chanies to the REQ p~ter DO longer ba"e any cff~. Wbm mc,jobi$ completed. BUSY is reset to "0". If REQ is still'"!". the job is irnmediateI>' n:.taned.
Wbil~

Slation-cxtr:mai S1 basic communication can c:<tecute e.... em-dri'-en data D"losf.".. for UaU'lple, paralleIlo C)"C[jc global data communication. Addnutng tbe nodes, en nncetlno,

The.e lim,tions address nodes thai arc on the ume \11'1 subnetwork. The node identification is denvcd from tbe :-'-W! address (DEST_ ID
pantmctcr).

These system functions set up the required communication links dynamically and - if 5(lt'Clllcd - break them when the job has been c:o:ecU!ed. If a connection cannot hi: established

StMATlC S7 station
I",_,=,,.=.m='"=~=c:~,,

:J_._. ~~~~ -.
T..... _

o...--~~IIon: ....... c.Iing SIrion. "......... _SFCaillin..- ........ "

______ 10, ....


_

,c~ ;;;;;~ ~

SIMATIC S7.tatlon CPO.! "in""CPO.!

c; ._

- '1~
,

rwo. .... ycon....::tlan' _ _ "'" .. 111\ SFC _In


o.w

I. .~ ~~ .o---.....~I

;;::l

~ ~

u_" .......

_ 0 1 ' cOOH_IiOo" ... \he d ...... it ....- . 1M .............. oySIem WdIft 1M dew.

ct"-

rwo. ...y conIMC!ion: l .....foorwlttl SFC <OIt '" _ _

~5

.:J
m

FI8U~ 2a . l ~

Station_Ex mal S7 Basic Commllllkotion

20 Main Program because of a lack of rt:so~s in either the sender or the rccci"er, ''tcmpoolTY lack or rcsoun:e~" i, reported. Thc InInsrer must Ih= be retried. Belween two communicatiOD partners. there can be only <)fie conne<:tion in each dircrtion.
00 a transition from RUN to STOp, an active conncctiolU (all SFC. except X_ RECV) are cleared .

20.6.4

S!'",~m FuneTioo~

fo. St a tlon-E .. urnal S7 Sade ComnonnlCIIllon

The fullo,,"ing syslem functions handle data t ransfers tx-n\"ecn ptu1n<,rs in d iffenlilt stations:

SFC 65 X SEND Send data SFC66X_RCV Keceivc data SFC 67 X_ GE"l Reat! data Wrile dala

By modifying the block parw.n~L<.."ffl al run lim~. you can ulilize a "Y"tetll func tion for diITcrent cOImm)l1ic~lfion links. An S FC may IlQ\ interrupt iu;elf. Yo" may modifY a program section in which one o f Ih~ sn :. is w.ed only in STOP rnnde; a ~01d Or W~rm ,""stan mUSI then be exe<;Ulcd.
U..er d a ta . data con.bl .. ncy
'fhcsI: SFCs transfer a m~.~imum of76 b)'l~"" of

> SFC 6K X_ I'UT


SFC 69 X_ABORT Dtscouncct
I'r~

The parameters for these SFCs Tnb!.; 20.16. SF C 6!1 X_Sl:S U Send d>lla

liste d in

user data. A CPU's opcnuing system combines \he u~er dala into blocks consistent within themse lves. wilhout regurd to the direct ion of \ral1sfer. The length of consistent traLl5fcrred data is ~ CPUspecific variable. IF two C PU, e.,<change data via X GET or X PUT, 1M block si7:e of the "pas,j;,'e" CPU decisi ve 10 dala consi.t~"T1ey of the truusf~rrcd data. In tho: ease of a SE:-I[)/RECEIVE al l <bill ofl call an: consIstent.

is

A job is initialed ,,";th REQ = " I " and BU SY " ''0'' ("'fiThI call") . While the job is in progrcs~, BUSY i~.et to "1 "; changt:s to .he REQ param~ cter now nO !(mgL"!" have any dr~"CI. \Vbeo the job terminate., BUSY is sel b ack 10 ''0'". IfREQ is stilt "1". the job i. immediately re.lltlc d .
On the fir<;1 call. thc opc: .... ting. system U"ansk.....

conn~":lion.

U data from the $(IU"", area to all intcnlal buffer. Ibm lran.fers the data tn the panner
CPU. BUSY h "1 " for the dumlion ,,(Ihe send pmce_ dl'rc. When the p!UU1cr has signa led thllt it has fetched the data. BUSY is sci II' ''0'' and the send job ttmllinated .

CIHt lil,:.urinl!; .... tlon -u t~rna l S7 ba.lc eUmmunkat lon


Staliol\_.;ltt~..,..,al S 7 ba.~ic eommun;eft!;on is a special case in Ihat ;1 requiTes DO configuring since dalD tran<fer i5 bandIed via dynamiC eonn~ct;oIl S. You simply usc an e"'stin" MI'l subnetwork or you ~...eale onc.

I(CONT is - "0'" the connectiun ;s broken and the respect;"e CPU resources arc avail ~ ble to
Olhcr communication links. If CONT i~ = '" I" , thc connectioo i~ maintained. The REQ_ LD parameter ma.lcs It J"lo<~ibie for yoo to assign an TO 10 Ibe Send data ",hieh you can e,aluale with Sr-C X_Rev.

Example: you have a d;vidl.-d S7-400 mouDtina: rack wilh OIle CPU 41 6 in each sectiOD.ln !iddi_ tiOD, you tOnll<'<:t an S7.300 .tation with a CPU 314 vin "0 MPI cable 10 One of the S7-400s. You confiaufe a U three CPU. in (hc Hardware Configural;ou. for elUU1lpk as '"networlwd" via an MPI ~ubnetworl<. You can now u~ stalionc xtemlll S1 basic commuDl.~alion rtnm all Ihn.-e cootrollers 10 e.~changc dbta.

The SD parameter describes the

ar~a from wbich the datn to be .,Ilt a1"C to be read . Actu"l parameters m~y be addresses, variables. or data areas ~d<.lrcsscd with an A."IY pointer. S~-ndand Recei,e data are nOI cb""ked fnr matching data

"P".

J2H

20.6 S 1 BMic Comm unication

'ill

SFC 66 ;'CRC V Rffetn d.t.

11>e Rehe data II.re pll(:cd in an intemal buffer, Mult Iple packets can be put in II. queue in
the chronoloKicllI order of tbcir arrival

Send and Receive daLi .~ not che.:kcd for matchioa <,!.atal)1'C"_ Whfll the Rccci"e <,!.at. are irrele\ant, II. 'blank" A}.l' pointer (N IL p()inter) as RD parameter io X_ RCV i~ pennissibl.,

Use EN DT r -0" to cl>ed: ... hether or oot <,!.aLi w= =ei\"~; if so. NOA is .. , .. , RET VAL .hoW!lthc number ofbytC$ ofReive <,!.ata, ami REO_ JI) i, the same as tbe corresponding parameter in SFC 6 5 X_SEND_When EN_OT is ~ "j", the Sf C tl>lll>fers the fU'S t (ollkst) packet to tbe dt stination afN; !-'DA is t!>en '. I" and RET_VAL M10"'5 the number of b}1es transfetTed. If EN _DT is "I" but there arc no data in thc internal queue. NOA is "0"_
On a cold or "'ann restart. all data packets in the queue II!'I: ..qCl:lcd, In the C\"C1\t of a broken eonn~oo or restan, the oldesl entry in the queue. if already Mque_ ried" ",it h E:.I_DT a 'il. is re1aiMd; otherwise. il is rejCl:ted li h th e other que ue <mu;e,_
1be RD parameter describes the area to "hich

SFC 6' X_G ET Re ad data A job is initiated with REQ - ~I " and B USY ''0'' ("first ~al1 ") . While the job is in progn;ss, BUSY is .Ct to " I": changeS to the REO parameter now no looger bavc any effecl, \\lhen the job tc-nn'nates, Bt)SY i. set hack to ''0'', If REQ i till "I", the job 1!l immediately rc;;tarted, When tile ~ad procedure has be"" imtiated. lh. operal;na syslem io the pwtnc-r CP U assemble, and sends tltt' <,!.ata required under VAR_ ADDR. On an SFC call, Ihe Rcive dala are emered in the oonrul1ion area specified al the RD parnml'1er. RET_ VA L then shows the nurn\)(,r ofbyt~s trnnsf=ed, IfCO!'.'T i. "0", the oommunication link ;1 bruhn, If CaNT IS "I", the oonnection i. m,in.

the Rci"c <,!.ala "'" to be wrinen_ Mn..l panunnets =y be ~.~ "ariables, or dal& area~ addre5Scd with an ANY pointer.

tained. The tbl& "'" Ihen lTad even when the communicalion pann.r i. in STOP mode.

20 Main Program The data are written even if the cOlmnunication partner is in STOP mode The RD and VAR_ADDR parameters describe the area from which the data 10 be sent are to b~ read Or to which the Rece ive data are to be "Titten. Actual parameters may be addresses. variables, or data areas addressed with an ANY poi nter. Send and Rece ive data are not cbecked for matching dala types. SFC 69 X_ABORT Disconnect

The RD and VAR_ADDR paramete,.., describe the area from which the data to be sent arc to be read orto which (he Reeei v~ data are lO be written. Actual parameter< may be addresses. variables, or data areas addressed with an ANY pointer. Send and Receive data are not checked for matching data types. SFC 68X]UT Write data A job is initiated with REQ - "j'" and BUSY '"0" ("tim ~al1"). While the job is in progress. BUSY is set to "1": changes to the REQ p:,mmeter DOw no longer have any effect. When the job terminates, BUSY I S set back to ''0''. IfREQ is still " 1". the j ob is inunedialely restaned. When the write procedure has been in itialed, the operating system transfers all data from the source area spe<:ified at the SD parnmeter to an ;memal buffer On the first call, then se nds the data to the panner CPU . There. the partner CPU's operating system write, the Receive data to the data area specified at the VAR_ ADDR parameter. BUSY is then set to "0".

REQ - .. \ .. break> an existing connection to the specificd communication partner. The SfC X _ ABORT can he use d to break only those connections established in the CPU's own s(;,t;un with the SFC~ X SEND. X _ GET or X_ PUT.

20.7 S7 Communicat io n
20.7. 1 Fu n damenlals

\Vith S7 commuu ication, you transfer largcr volumes of data bet\vun SIMATTC S7 SIalions. The stations are connected to each other via a

StMATtC $7 su.tlon

SIMATIC S7 $t$lloo
tto \>l ~

, ~=rvrn 1"1

CPU o",,_y co",,_ellon: In the C~ ~ litlg station, ""no!<or I. wfV\


FBISFB ""' . in UOOf

1., :'t'''' ~I~I= !1' -I ~


program

Co.mectioo

ce"

Connection 13b le

":'";.::0
u ....
, ~tm

in the CPU o" ....... y conrr.crion: In l~. de"vertng


p< "''''

letc!tes or _

.""ion,"'" operati"ll tile


d~ta

" j"
Two-way co.on. clion;
T ........

" j

f.' wtth FBlSFS cal if1 u.er p;og"""


.. <-~...

-" = - "
SfB

II

- 12113

Sub"'"

MPI. PROFI BUS, I""""'", E'he,".,


~'il!u r.

20.25 S7 Communication

20.7 S7 CommWlicntion 8Uhnern oM<:: !hi> "an be an I>fPl subnern or!<. I sulmctworit or aD Ethernel _ubnel_ work. !hi: communi~-.t1i(>1U connections are '!alic; Ihey an: configllred in Ihe connection lahle ("CQmmUIlicalion yin cQnfigu",d connecTionsn).

rRormus

With the 57-400. the ~"<JmmunlcaTion, function, are sy,L.:m !Unction bloch 5FB. integnu~-d in Ih. OJ"-"TlILmll ~y~lcm ofth. cru . Thc a~!-OCI' alCd installCe data block i> localed in the uS"r memory. ffyou w"nl to use 57 communi~al;on. cupy The inlcr(~ description ofthc SFD, from the Standard Llbrar)' umkr System FUMri"" Blocks to th~ Blucks container. gcncrale an in"ance data block for e,",h call and call the SFB with the "">ocialcd instance dam block. With inC"'lIlcnlal input. you can alw ,ciCCI the StS from Ihe prog!U1l\ ckm<;"nt catalog and ha,.. the instance dal.!< block gencrated automati.:.lly. Wilh the S7. ]OO. the communi.alion functions are standard nmcnon blocks FD which :'ou Cln find in the Sta~d(J,-d Library under Communication Blocla. Copy the funcliQll bLocks you wisb To usc ;nlO thc ~"()!lTaioer Bloch and th..... u.~ tb<.m just like Hnormal'" fuoction bloch. Confl llurlnll S7
eommllnk~tlQn

parmer clIO he eslabli;;hed. lnitialiulion blk"", place m tJx, CPU IMt ",,"c;,es the anributc "'Aeli,-c connection buildllp - Yes" in The can ncction ,,,]:)Ie. You call 111<.0 communicaLion blocks u..ed in cyclic operaTion in a r<:!Slnn OR and mitialize Tbe paratnClel"i (pro~ided they "re ""aillble) llS follo\\s:

> REQ "' FALSE


t>
Jl) -local cannlion lD fiom Lhe COIUWcIlolltabk ( <.lata Iype wo~n \v# 1 6~~xxx)

> R_ ID - jub II> " h ich you can design for a


pair o fblocks (datalype OWOMO DW-I6><xxxx xx.'I..\) ,. PI NA 'IE

P-=.PROORAl>I" in ASCI I ~<>dino: (c_g_


ARRAY[I _9) OF CHAR)_ _

variable WiTh thc contents

The block> must continue LO he caUed in I program lOOf! unril the OO'ffi parnmcTer h.as ~i"al 'wc 'I~. The partmClers ERKOR and !iTA TUS IIhc informnlion ~unccminlO the elTOJ1l lhal ha"c o.:~urred and lhejob '1"luS.

The prc~u;~;Te far die 57 commu.nieaTion is" confillured conn~-.:'ion Illble in wbeh the ~vm' municatian lwks arc defined.
A communication link. is specificd by a conne<.:lion to rar e~ch communication partner. STEP 7 as;;igns the con nection ID~ when it compi les thc conneCL;On tabl... Uw the HlocaIID"to initialize Lbe FD or SFB in lhe module from \\hiCh the connection i. 'iewed. and tbe """rcm.01~ 10" to initia\i<c lhe FE or SF8 in !hc partner mod ule .
logl~....t conne<:TiOD can be u.cd far different' 5cnd!Rec";,c ~UcSIS. To di<IIngllish bcTWCCll IM-m. you mUSL add I joh 10 To the connectIon 10 in ordC1" 10 define th~ relaTionship be"'.... n the Send hlock and Re<:eivc block.

You do nOt need to 'WilCh the daTa are"" aT ",stan (cone"", Ihe panunclCf'S AOIl R .x, RD x and SO >;). E>;c~"f'Iion in S7-400 sy. Icm'i: wnh SHJ 8 USE"O. SFB 9 UR.CV, SFD 14 GET and sm J 5 rUT, the communication bun'c'" for t:t11lJamccin& can,ish:ney are created wben called ror the fm! time, and Ihese Miloe Ihe maximwn data quanlity pcr transfer M.n further call .
C~

ellc opcra lion

In cydie opermioll. you CII IThe cornmunic:ttiun

The same

blocks absolutely and you conTrnl data Tnm~f... \ ia the pafILmeters REO and EN_R. You mu)1 cvaluate the re.ults in the NDR. DONE, ERKOR mol STATUS J')BrImet<"N ;nUTIed;aTcly rollowlDll cach Pm<:essinll of a commW'O icBliOIl bloc\. since they are on ly valid up 10 the n~~T call.
\\~th the S7-300, paramC1C1'l1 ofdalB Type ANY (SO_I. MO_ 1. AOOR_I) can only be supplied with fllas and data as the address_

20.'.2 TWa-Way

D.". K~"haD l;:e

t nili.ltUll ion

.so tru" Lhe

57 communication m",,' be iniTialized at RSLart cOIln~-.:lion to The commllni~RTion

For ",'o-",Iy data e:wh.nlle. you require fJOC SE~"D blo.:k and OIle RECEIVE blo.:k "ch al the ends of" connection. 80th blocks carry the

20 Main l'ropm

Tab'" 20.17 FB/SFB P"",met=< for Sct>dtng and Rc<:",ving Data

BOOe

"""e

WORD

Bom

New .Jata fetched


ErT(>1" occurred

SD_2'J
SI)_] t)

"
RD_ 2 Il 1U)_3 "

, , ,
OUT

"'''''

'00
Second Send II/"Ca
Third Send ""'" Fourth Scr.d area
S~cond Ht(;~he .rc~

Th ird Receivt

~rc~

Founh Roce iye area

cortne>clion lO s thll' are located in the cOnDec,ion table in Ihe $ame line . You cattalso u.~e sevCOI l " block pa in; which are !hen d;s';n\li~hed from eac h other by Ihe joh ID. Thc ruUuwin SFlls arc a~ailable for ." ....,,"'y du'~ inlCTChange: ~ FIlIS FIl R USEND Uncoordinated send ing of a data p.d';~l uf CrU-specit1c lenglh
to

FB g USE-"':U a nd FD 9 LKCV

S . ' H 8 l.S .~ND and S . 1:I 9 L" RCV l:ncoordinaled . .. nding . "d r K e;';n/!

FliIS!'"A 9 U RC V Uncoord inat ed recei vin g ofa CI'U_~r<-..,i{k kong!h

d",~

packel of

The SD_x and RD_x parameleN aTC used to specifY the vari .. blc 01' Ihe arc" )'Oil wanl 10 transfer. Send area SD ~ DlIlSI corro~pond to the rcspe<"Tive Receive area RD It. Usc p"rameters withou t gaps. I>.:jfinnin!l wilh 1. No value s need be specified for tlllneeded pa\'8meters (like an FB> not "II SfB pnrllJnClc,"" n~cd be US5igned value ,).

'h"

J>

F BlSF B 12 BSEND Send ing ofa dam hlock of up 10 J2 or 64 KB in leng,h FIlISFIl IJ DRCV Rcccivinil of a data block of up 10 32 or 64 K.D in lenglh

J>

A posilive edg~ at the REQ (Te quc~.) p"r ~me\cr staru Ihe ru,.'a exchange, positive edge al the R (TC'ct) parameter abom il. A 1 in the EN_R (enable recej"e) J"lT&meter .ignals that the p;lrtner is ,-"ady to n:cei\e data, -0 can be used 10 abon a current job.
When the KDR parameler has ""umcd the valu e J following the dala transfer. call th e bloc;': "!lain - this lime With EN_ R _ 0 _to p",veD1the recei . <; area from beinlO oyerwnncn by new dat a during the <t'L" evnlllMinn.

FI:lISFH li lind FRI SFB 9 or FB /SFIl 12 .. nd FBI SFB IJ nillst always be lL'led "" a pair. T" c parametel"\l fOT ,h",c S H 1. 8'" li~led in h bl" 20. 17.

20.7 S7 Communication

!.oitializ. the ID parameter with the connection ID. whi ch STEP 7 enters in the connection table for both the local and the portner (th~ 1\''-0 IDs may ditTer). R_lD anows you to choose a specifiable but unique job 10 which mll>! be identical for the Send and Recei,,~ block. This anows sev~-ral pain; of Send and Recetve bloch 10 share a single logical conne~\ion (as each has a unique to). With the S7_4OO, the system function blocks accept the acmal value< of the ID and R 1D parameters into their instance data block onthe first calL The first call c<tabli,he, lhe eommunkation relationship (for thi, instance) umilthe next warm or cold start. With the S7 _300. you can change the assignment oflhe ID and R ID p;t]1l.meters follo",ing each completed job. With signal state " 1-' in the DONE or NOR parameter, the block si gnals that the j ob terminated without error. An eITor, if any_ is flagged in the ERROR param~ter. A "alu~ other than zerO in the STATUS parameter indicates eilher a warning (ERROR - "0") or an error (ERROR
~' I") .

block again _ this time with H..J_R "0" - to prevent the recei "c area from being overwri lt en by neW data during the data evaluation .
E

Initialize the iD parameter with the connection iD, which STEP 7 enters in the connection table for both the local and the partner ( the two IDs may differ). R_ ID allows you to choos .. a 'PC~ ifiable but unique job TO which mLlSt be identical for the Send and Receive block . This a!low , se,-eral pairs of Send and Receive blocks to share a single logical connection (a. each has a unique 10). W ith th e 57_400. the system function b lock< accept the aClUal values of th~ 10 and R_ ID parameters into their iDStan~e data block on the first call. The fil'lt call establishes th e conununication rdationship (for this instance) until the next warm or cold SIan. With the 57 -300. you can change the assi gnment of\he ID ami R_ ID parameters follov.i ng eacb completed job. With sigoal state "I" in the DONE or NOR parameter. tbe block signals that the job termi nated without error. An eITor, if Bny, is nagged in the ERROR paramet~r. A va lue other than zero in Ihe 5TATUS parameter indicates eithe r a warning (ERROR~ 'il") or an eITOr (ERROR

FB 12 BSE ND a n d FB 13 BRC\' S FB 12 BSE:"n and SFB 13 IIR C\' Blo ck -o ri ented s~ndl n g and ,"" c .. i,in g
Emer a pointer to the fil'>t byte of the data area in parameter SO _x or RD_ x (the length o H m, act ual pararn~ter detennines the maximum size of the communi~ation buff~r when called for the first time_ it is not evaluated w ith the further calls); the n umh<"r ofbyles of Send or Receiw dBta is in the LEN pa",mcter. Up to 64 KB (3 2 KB with non_ integrated iDlerface) may be transfe"",d; the data are ,raru ferred in b loch (somnimes ~alled frames). and the t",n,fer itself is asynchronous to the user program scan . The LEN pammeter is updated following each recei"cd b lock. A positive edge at the REQ (request) parameter starts (he data ex~ha.nge. a positi"e edge a'the R (reset) parameter abort' it. A " I " in the EN_ R (enable receive) parameter signals that the partnet IS ready 10 reeeive data. "0" can be used t<J abort a current j ob. When the NDR parametcr bas as,umed Ihe value -'I" following the data transfer. call the

_ or).
20 .7.3 OD e- Way Data Exe hang.. In one-way dala exchange . the eonununication block oall is located in only one CPU. In t h ~ partner CPU_ the operating system handk< the necessary communication function< . The following blocks arc available foronc-way data int~rchange
~

FB SFB 14 GET

Read dala from a panncr CPU


> FB/ SFB 15 PUT Write data to a panncr CPU

Table 20.1~ lists the parameters for the, e blocks. The operating system in the parmer CPU collects the data read w ith FH/SFB 14 ; the operating Sy<l~m in the panner CPU distributes the data written with FB /5FH 15. A Send or Recei ve (user) program in the panner CPU is !lot required. The partner CPU can prov ide the

333

20 Main Program
Ta b l~

20.18 iFS ISPS Paramete", fOj" Reading .nd Wriling Dala

ID DONE

ERROR

S1ATI..'S

" " " " " "


" "

INPUT
OUTPUT

WORD

ROO'
ROOt. WORD

Job terminaleJ

OUTI'U>"
OUTPUT

Error occurred
J"b iit.im Second data area in p'rTn~"T CP U Third datil arc. in partnej" CPU

'0

,
Sc"""nd Receive area Third R~c.ive ar Fourtb Receive "'OH

RD 2 1)

'0~3

1)

" " "

kW
A.,.'iy
A },'Y

Se<:<>nd Send area n .ird Send arca Fourth Send =a

,"'

required communications ,ervic es both at RUN" and ST O P. The size of the transferred c onsistent data blocks depends on the (sernr) CPU used. A positive edge at parameter REQ (reque st) starts Ihe dala in terchange . Sctthe ill parameler to Ihe conn<""Ction [0 emered by STEP 7 in the cOImection table.
With a " 1" in the DO:'-lE or :'-lOR parameter, the block signals that the job te rminate d withoUl error. An error, if any, is flagged with a '" I" ill the ERROR parameter, A value other thall ZerO in the STA T US parameter i;; illdicative ofeilher a warnillg (ERROR = "0" ) or an error (E RROR ~ "]"). You must cvaluate the OOl\-:E, NOR. ERROR and STATUS parameters ~ft~r el'ery block call ,

Unn eeded paramet~rs nced nOI be spec ified (as in an FB. an SFB docs not have to have values for all parameters ).

20.7.4 Transferring Print Da ta


SfB 16 PRlNT a llows you to trallsfer a format description and data to a p rinter via a CP 441 communications processor. Tahle 20.19 lists the param~t~rs for Ihis SfB.
A posi ti ve e dge at the REQ parameter stans the data exchange with the printer specified by t h~ 10 and PRN_ NR parameters, The block signals ~n error_free tran s fer by setting DONE to "\ " . All error. ifany, l S fl~ggcd by ~ '"/"' in the ERROR paramete r. A value oth~r than zero in the SlATUS parameter is ind icat ive of ei ther a warning (ERRO R = "0'") or an error (ERROR - ' "1") . You must evaluate the DONE, ERROR and STATUS parameters after every b lock call.

Use the ADDR~n parameter 10 spe~ ify the vari~ble or the arCa in the partner CPU from which you want 10 fetch or to which you wanl \0 send th~ data. The ~reas in ADDR n mu,t coinc.ide w ith the ~reas specified in SD ~n or RD_n. Use the parameters without gap', beginning with I.

Enter th~ ch aracters \0 be printed in STRING fOIDmt in the FOR1l1AT parameter. You Can

20.7 S 7 Communi~ ..ti(>1)

WORD
ERROR STATUS
OUTIUT
OUTPUT

'00' WORD

Error occurred Job .tatu.

Second vwioble Third ,..nable

integnlte as many as fOUl format descnpt;ons for variables in this string. defined in parameIC1"5 SD_1 10 SD_ 4. Use the parameters wilhoul gaps, belllnnin!> with I; do not sp~iry values for unneeded pammelers . You can tran~fer up It) 420 byl"", (Ih~ sum of FORMAT and all "arisbln) per print req uest. 21l.7.S Control FunCTions The following S FS. are available for conlrol hni Ihe communication partner:
I>

{ERROR'" '"()") or aD error (ERROR - 'r). You mus' evaluate Ihe DON E, ERROR and STATUS parame,crs afte-r e'"t'ry block call. Specify as PI_NA:-'-ffi an array vnriablc with the eonlents "P_PROGRAM" (ARRAY [ 1..9] OF CHAR). If you do nOI a"ign IhC A RG parameter. a Warm start is triggered in the partner controUer: ifhC" is a5si~cd 10 ARQ a cold SIan il trigaered if permissible in Ihe pan"er C01IlrolIer. The IO_STATE parameler is currently irrele'1IIIt. and need nol be u,igncd a value. S FB 19 START eX~Ules a cold or wano restart of the parmer CPU. Prerequisile i$ Ihallhe pan_ ner CPU is 81 STOP and that the mode Kkctor t$ posilioned to enher RU>! or Ru>!-P. S t-8 20 STO P setS the panner CPU 10 STOP. PITrequisite for error-free ex:ution of this job request is that tI,e panner C PU is not al STOP when the request is subm itted. S Fa 21 RESUME ex:utes a hOI reSlart Of lhe panner CPU. Prorequisite is Ihul the parlner C PU is at STOP. lhat Ihe mode selector is sel to either RUN or RUN-P, Bnd thaI a hot .... stan is penni5sible althis lime. 20.7.6 :'olonitorill ljl FUlled..,ns The following syslem blocb are available for moniloring funclions (> SFB 22 STATUS Check panner stalUS
!>

SFS 19 START E.",eute a COld or warm restan in Ihe panner contrOller SFB 21l STOP Switch the panner controller 10 STOP SFB 21 RESUME EKecuI" a hOI rcstan in the panner comrol'
["

(>

(>

These SFBs are for one-way data exchange; no U pmarom i. required in the pnnner de\"ke 5er for Ihis purpose. The parameters for them are listed in t.ble 20.20. A positive edlle at the REO parameu,r SlaTU the data exchange. Enter as m parameter Ihe connection ID "hleb STEP 7 entered in the eonn~tion lable. With a MI" in the DOI\'E parameter. the block signals that the job tenninated without error. An error. if any. is flagged by a "I" in the ERROR rnnun~ter. A valu~ other Ihan zero in Ihe STATUS purameter is indicative of eilher a " 'aming

SFB 23 USTATUS Receive partner SlalUS

20 Main Program

l .. b le 20.20 SFB Paramelers for Partner Controll er

"
OUTPUT OUTPUT IX - 0=

BOOe
~y

Error (){; urrcd

M"
.

"
Pre",nt in SI'II

"

IX_OUT

~y

'ro_

With "C" a. the value. cold "art js triggered in Ihe p8r1n<r controller. ifpermi"ible IITelennt

" '" "


Declaration INPUT INPUT INPUT OUTPUT OUTPllT
O~UT

BYIT

Tab le 20 21 SFB Paromotero for Querying Statu Parameter Dat. Typ'" Contents. Doocription S.." data eXChange Ready to receive Connection ID New data fflched Error o<curred Job,tatu. Phy,ical statu. Logical 5tatus Status of an S7 CPU as pa"ner

REQ EN_ R
ill

NDR

ERROR STATUS PHYS


WG

LOCAL

" . " " " " " " "

" " " " " " "


"

BOOe BOOe
WORD

Booe Booe
WORD
A~

IN OUT lX_OUT

ANY

IN_OUT

A"Y

(>

SFC 62 CONTROL Chock statuS of an SFB instance FC 62 C CNTRL Check stalus of a connection

(>

status). LOG (logical status) and LOCAL (operating Slatus if the partner is an S7 CPU) parameters, A positive edge at the REQ (reque>!) parameter starts Ihe query. Enter as 10 parameter the connection ID which STEP 7 ~'T1tcrcd in the connection lable. Wilh a " I" in the NDR parameter. the block signals that Ihe job terminated without error. You mUSI evaluate Ihe NOR. ERROR and STATU S parameters after every b lock call.

(>

SFC 87 C_DlAG
Determine connection SIan,s

The parameters ofthcsc b locks arc described in Tables 20.2 1,20,22 and 2023. The following applies for these sy.lcm blocks: ao error is indicated with "1" at the ERROR param"'1~'T. If the STATUS parameter has a value not equal to zero, thi' indicales either a warning (ERROR - "0") or an error (ERROR "I'').

SFB 23 USTATUS
R ecclve the natus oftbe p artn er device SFB 23 USTAl'US receives the slatus of the partner. which it sends. unTcqucsted, in Ihe event of a change. The device staN' is dis, p layed in the PHYS, LOG and LOCAL parameters.

SFB 22 STATUS Ch ee k the st atus of the partner d e " ice SFB 22 STATUS fetches the status of the partner CPU and d;<play< it in the PIIYS (physical

'"

20.7 S7 Communication

. Tabl, 20 22 'Paramet=< of the Block< Fe fi' C CNTRL and src 62 CONTKO)

~:-BK
OFFSET

"

SFC SFC

~
rt-.l'I Jf
I N~UT

,=c
BLOCK DIl

instance

d.,. block
,om

"C

WORD

Numkr of the local instance

W
RETVAL ERROR

Fe

L,",PUT

I "c
.
REnJR"

~
,=c
,~

INT

Error ;ntormat;on
~.rro' <iele<:ted Statu, wora

K
FC

SIT

oun'tTr
Oun'UT OUIT",
OUTPllT OUTPUT OUTPUT

,m

STATUS
I STATE

"C
SFC src

WORD IWTf.

' _CONN
I STAniS
C_CO~

src sec

Bool
WO~D

Block 'YI'<' iJenu AOLual ",ILl> identifier ConmTtion ,..,'"


("1" - ~onnc"tion e~i",)

Ii.,

STATUS p"rmnde, fo, communic.,;on

FC

OUTPUT

,=C
WORD

in<tance

eI

Cotllle<lion "atu' ~ - connection exi,ts)


Co~jon

C STATUS

"

OUIl'I.l

""tm

A" ''" '" the EN_R (enable f~cei"e) p"ramet~r signals that me parln<:r i, Tcady 10 ....c~i,c data. lnitiali~c the TO parameter w ith the co nnection 10, which STEP 7 enters in the conne~tio!} table.
With a "I'" in Ihe 1>.'DR paramC.,cr, the bloek ,ig_ na ls that the job terminated without error. You mmt eva\t13tc thc 1'.'DR. F.RRO}{ and STAI'US paramc tcr. after ~,'ery block call.

al lhe' DB parameter. You mmt evaluate the NDR. I:RROR and STATUS par-unctc,.,; after "wry block call. Th " parameters '_nrP. , STA:IE, ' _ CONN ;lnd I_ STATUS prO" ide illformm;on con cerning the statu., of the local commonication instance.

SFC 62 CONTROL Ch~cll the ~r!ltu ~ of 9 ~ommunicarion instance


In S7-4-()(l 'ystems. SFC 62 CONTROL det~r mines 1he Slatus of a commnnication instance and the associatcd ~onncC1ion in the loc" l ~on troller. Enter ,ne SFB', instancc data block in the I_DB parameter. II the SFB is called JS local ;n, tance, 'pe<:ity the number of the local instance in the OFFSET parameter (zero" hen no local in51ancc. 1 ror the (irst local inSlaoce, 2 tor th~ second. and so on).

Fe 62 C_ C:"<TRL Check thc ,tatm of a connection

In 5i-300 sy<1em<, Fe 62 C_CNTIl.L determinc~ tn e status of a connectiou in the local device. En tcr the connection ID in the '0 pru-amd er which STEP 7 dcf mes in the connec lion table fo r the local device.

With si gnal "atu, "I" at thc RN_R parameter (enahle 10 receiv e), the actual connection ,(a~US is di'played. Th~ ERROR ami STATUS par-.m el-Crs must be eyaluated foUowillg each block
~all.

Wi\n signal slatus "1 " at tho EN _R paramc'~r (enab le to receivc), tne Sta\..s of Ihc commun ication in,tance is displayed which is spee itied

Thc C _ COt-<"N and C _ STATUS parameters pro,ide information on the acrual ""mnection Sla-

tu,.
337

20 Main Program

SFC 87 C_DIAG Iletermlne thc connection .Iatu.


The system function SFC 87 C_D1AG determines the a~tual status of connections wilh a r,xed configuration, i.e. all 57 connections and a ll fauIt-tolernIlI S7 ~onnections. With each call, the SFC 87 C_ D1AG reads the conne ction data from the operating system and enters them into the uSer memory for cvaluation. The SFC then aeknowledges that read ing has taken p l ac~ in the operating system so that a change in status since the last read operation can be recorded . If you wi,h to monitor the connec_ tions pennancntly. call the SFC at r~gular intervals. c.g. cvery 10 secon ds in a lime imerrupt organization block.

job with signal status hJ" and the REQ param_ eter. Tfthe job cannot be executed inunediatdy, the SFC returns the signal stmus "0" on the BUSY parameter, othen'hse BUSY ~ "[" means thaI the job is in progress. Table 20.23 ,hows the parametcrs of SFC 87 C DlAG.

SFC 87 C_DIAG can work in "l'ario", operating modes which you Can sel using the MODE parameter;

> MODE - 8#16#00


Tbe SFC acknowledges ,"<,ading out, witb out copying the conne<:lion data.

SFC 87 C DlAG is a system funclion which operates in asynchronous mode. You trigger a

"" MODE - B#161101 The SFC copies the connection data and acknowledges reading out.

IIData

bloCk with

~he

c~~ect 1 on

data

con_~e<"!

OClOL;

cc<>_busy <:en e=or ca"J_ inde>< =_6tatus

BOOL,
1m;

Sl"BY COl<

>==

OJN_lP s:rAT_OJN

-,
~,

I/n-i gger j ob I Neb running IIError informa~1cn of SFC I /~r ot field eleme:-.t ~ read by SFC
[1 . . 12]

WORD;

/ /C=.r-"ct:ion
//Connectian

OF STRUCI" IJ
~tatus
producti~ connecti on of standby connect i on tolerance (.. i~hout ta'~l t tol e rance I

BYTE;

DLS_PCON
DIS

=0 -,

BYr"E, BYTE, OClOL;

BCOL,
8l"1>,

IIPa rtial connect i on number IIPa reia l connection nurnb~~ I 1C"han~ in ... ~at:"",, in f ... ult / /Chan9'" in .. ~at-,~ of conn. IIRe"erved
!/~&erved

o!

BYTB;

You Can usc your own expressions for the names of"ariables and compone nts. The call could then be as follows, for example:
CALL C DIAG

=,
PEr_VAL

~O

, ~ oon_data.oon_~,

,.

Bi/16/102,

Figu,"" 20.26 Progrornminll Example ofth" SFC 87 C_DIAG

'"'

"-"'" =-

00"

,_ ". :_ :_

con_ data .oon_arror, cou_data .COI"l_buey, cou_ "",,ta . co'L1t:>dex, cou_ """ta.corL,,t.atu3) ;

20.8 IE cmnmUJ1kation

"
I>

MODE - 8';161102 Th~ SFC only cop;e, th~ COun~"tiOil data if they have changed, and acknowlcd~es reading om - even ifno cha0i:cs hi"e occtUTCd. YlODE '" B# lbI'03 f he SFC c(I,ne$ the conn..,l;on daT !Ihom a" admo" kdgmg.
S~C

dance with RFC 1006. or UDP in accordance w i.h RFC 768.


Th~ communi cation fu.uctinns arc loadab lc function blocks (Flh) contained in lh.. Stan. daro LibruT)' of STEP 7 und .... Cmnmuni<:atlon Blod .... included ore user-ddinetl data typ<:S (UDTs) with the Sirurrure of the connection da til .ud .he addNc .. of lh1: WTIImunication fl8rt. ncr.

I>

87 C_DlAU tnon,milS the acmal ~onnection <iali from the opemTinj; sy,t~m into the de~ t inntion area spccifkd ;n the CON _ ARR paramctCT. The d~.t'nntion arca is II. field of .,mclures: a field COnlpon-.::n1 contaim the data for 0Il~ conntt1;OT1 . The number of field elemcnl~ ($IrUCI~) must corTbpond 10 the nomber of pomble connccl;()n "l. Figure 20.26 ,hmn the pos.iblc ,lruc<Ul'e of a corresponding ficld variable with the cOIlll.c\ion data. The

Cnuflgurinl: IE comm u ni cation


Tbc follo"ing are ",qll;~ before data traIl,f<..."-,,d "im ro communication;
t:>
call

be

In .he case of the protOCOls TCP native aud


ISO-ollTCP. ~ conneclioll must be ~SUlh hshcd to the commUnic"lion pmtner (cnn nccl;on-oriented prol,-""olS) or

The field with tlw connection data h not

I>

arnmg..o according to the connection llh: the


indi~idual tonne~"tiOll> c;m b.-, a,"gned in any rnlUlJlct to the field el..."enIS. FIeld elellK....m with inva lid connections c"",, al$O be "",,.itioned belween field elcmcnt~ "itn valid connt'<;lions. Th e d ala of a conne.;tion nre cousiSH;nl wi lh nne ano mer.

In the case of the protocol UDl', a eOUtle<: rion mu>1 be establiShed 10 .he communica tion 13)er of the CPU operating "Yl'tem ('Oconn~c.ionl.",'i prnlOCOrO), The parm .... is t!>en addn::;;sed when the "'levanl [mlct'..,n block is called.

ZO.8 IE co m m unlca lion


20.1 1.1 Baslc5

With "Open communkalion ,'ia Industrial &lb em~'" (IE communica.ion for don). yoo transfer data bc.wun 1"0 de"ices connCCted to the cmcrnet ,...bnc: . Conununication cllIl b.-, implemented using the prutorols TC P na.ive in ;te. cordance with RfC 793, ISO-onTCP lD a<;<;<)1"'

The cOOlle<;tion is coniig\1rw via a dal~ area (nol \I.ina th~ con"ection table). The nC<."(:!ISIlI)' dati. ~UUCtures ar.. "on.-d in the u .....--defined da ta lYPe lo TlT 65 Tro:-S_ PAR that the function bloch use fOT establ"'hin~ and cic".uina down the COOll""I;OII, Thc dala contain the connection 10 !hal Stale' a specific connection and the liS' s<)C;a.e<l Ii.lllction bl",,~ ca ll s, and the informa t;on on the proto;;ol wed. 8tahlishment of the oonnectiuo
I<)

the partner or

.settIni lIfl or the conununkation access point h; hoindled by !be funcrion block f lJ M TCQ:-I that )00 call in the main progmm ..,rboth panncrdevic~~.

T>6U1. ca.n

~ trapsf~,-red

in parallcl in b<.>lh

20 Ma in Pmgram

CPlJiCP "":~
o~

.,...on,

03t& ""nsfer I'Oth tiD P !>"'locoI


\;6 CO, Jt~ ~

' __1 -:1' :J" __


671GB . . .

, :J

.'

I'lgu..., 20.27 IE couunuuicatioD

directions over an c~' a blj<h ed connC~';()T" Sev_ ~ra! cOll1leclion'; ~an exi<l oU one physical lin". The function block PH M T OTS_ CON ",lea,s lh~ corUlcclion dov.'ll again and 'hus relea.;;e, the resour"". used (Figure 20 .27). With the funclion bJocb FR 63 TSEND and FE 64 TRey' you can tnUlskr dat~ wi lh lh~ NO\oeols TCP native or ISO-on-TCP. Dat~ twn>fer wilh the UDP protocol requircs the f"ne tion blocks I'B 67 TUSEND and FB 68 TURCV. Whcn calling these function blocks, specity the address of the partner device in a data a,...a, The strucrnre of this ",Idres' is in the us~r_defined data type UDT 66 TAD!)_I'AR. Calling fuuction b locks Thc fUnClion blocks for IE communication work ~synchronou8 Iy. that is,joh execution ~an take several prol,,'T,,m eyde8 under certain drcumstances . You can call thc c0ll111l1mication blocks in the main program and control d"la u-an,k"T wi th the parameters REQ and EN_R. You mu,t evaluate the results at the p"rameters DUSY, NDR, DONE, ERROR and STATUS

immediately after each exttldion .ince they only remain valid unti l the next call. 20.K2 ESlablisblnl: lind clearIng d",,n .>nn ~cttons Bcfore data can be U-ansierred with IE communication. a cotmection must be e,tablished w ith thc partner device ( in thc c~se of TCP native and ISO -on- TCPI or wi th the communication laycr of the operating system (in thc case of UDP) . The following blocks are available fur this purpose:
I>

FB 65 TCON E"abli,b cOTIDec\ion to the communication partner or thc communication laycr of the opcrating 'yst~m FB 66 TD1SCO:'>l C lear down connection UDT M TeO "" PAR Stmcrure for the counection data

""

[>

You can tiud the parameters o f the function blocks in Table 20.24. The <.ie,ign of thc data structure is ,bown in Table 20 .25 .

HO

20.8 IE communicatiun

To bl.10.14 !'I",me'er< fur Fa 6S TCO r- and FA M TDJSCO~

BUSY ERROR

65

66 66 66

ourPIJT

65
6~

OU11'UT
OlJTrtJT

Job bt'iDa ptOC..K<l (-Ii"'" hu bt' .... compl.1.ed (""(1"1 Emr. oc.:urred (II -I~)

STAn;S

Job f~u'."""" onformalion in !he .~.., ofl!Rl!.OR

UDT 6S TCON P.....

l'!~~~~~;;;======
",ference

,.s ,. """"""",," """ "" , 000'


..,he " ..

WORD

W :< 16=OO(IO
B ~16'101

C~ti'""

V. 1IIe ""'!ole: \\ ,, 16WOOO1 to W 16o(tFFF

Conn""""" Tcp1 P na"v. !)"pC n-l~1


(coml"'ibih,y m<><Ic)

..

a# l6/j l 1:
R ~16oi 1~ :

8"164IlJ:
'1'''''

um

TePIll' nat;'. ISO on Tel'

"

"

,
"

, .

,ice (_ TtIaIWIJ
llYn :

l",,"l_tsap_
~

BnlM02
l1'116::00
S ~!6.oo

Leni'h of

pano.tn"'' ' l""oU""l'_'d

rem_,ub_
~,

,,"

remj taddr_

"

.m
IIYlE

CUrTmlly "'" uoed

l.enJlb of 'he add",,, of ' he romot. ''<In,, ,,,,';on


point; _
~

with VDP

"'m_....p_ i<Ucn

.m

B!f16"OO
S ~ 16>oOO

DO"<

L""i!lt ofpaamelerrern_ .... pJd: IIA<!d. "iii! UDI'

,,J4 ,u

rem_ mbn", ",m_"addr

" .. " "

" "
"
SO-

AI{RAY [ 1..6) OFLWTF ARRAY [l .6] Of BYTE ,"RR/,S [1..l6]


orSYTE

6(B~16"OO)
6(R~16"OO )

C"""ntlY!lot used

rem_....p)d

16(B# 16ioOO)
6(8"'16fIOO)

n.,,_otI<I<h

ARRAY [1..61 Of IWTE


WQR!)

.""

W .. 16IIOOOO

Ii' addfc" uf t11e re[l1o'e ron""",iun pOint; no. u ... d IO.i.h UD!' I{emo,. port number or relllUU' rs,\P; "'" u>oed "ith UDP R.ttek and .Iot of obe 10.::11 CP; "'" uoed whh UDp \1 .... be ""&/1..0. W~16l'OOOO

20 Main Program FB 6 6 TD ISCON E!tablbh ~t1nne~titln Function block f B 66 TDISCON te""inales the pr<"requisites for IE communicat ion, It clears doY.-n the connection to the communication partner ur de let., s the communication access pumt. You des ign ate the communication connection by assignin g m e ID parameter. The specification must correspond to the v ariab le id in the connection data,
In the initia l state. the parameters REQ, BL' SY, DONE and ERROR ha"e s ignal ,ta,e "0 . Vuu

F'B 65 TCOK
E ~tll bUsh ~onncction

FWlction block FB 65 TCON cr~atcs the prereq uisites for IE communication . The parnmeters required forthis arc located in a data area that has the structure of the user-d~fllled data!)pe UDT 6~ TCON_ PAR.
VvbCIl using the protocols TCP native and ISO on TCP, a conmx:lion is establi.hed to the communication partner. The station for which -'A ctive connection serop" i, entered e,tab1i8bes the connection. Thcpartner stlltion must then be designated as )lassive_ This designation is independent of the d irection oftnUlsf~r of the data,

start conne ction cle ardmvn with on the REQ pammeter,

II

rising edge

The connection is monitored and maintained by the operating system of the CPU, In the eve nt of a break in connection, the active panner a t_ tempt. 10 re-establi sh the connection without having to caU FB 65 TCON again. FB 66 TDlSCON clears down the communication cunneeti on in STOP mode of the CPU or in th~ case of POWER OFFION. If thc UOP protocol is used, fB 65 TCO!" s~ts up a local comrr",mication access poin t that re;>resentS tbe connection be m'een the u,er program and the communication layer of the operaling .ystem. No connection is made to Ihe connection panner You designate the communication connection by assigning the LD parameter, The spec ification must corrcspond to the variab le id in the connection data. You spec ify the ~onnC<' tion data with the puinlcr at the CONl'. CT param_ " e te r, In the itlitial state, the parameters REQ, BUSY. DON E and ERROR have signal St at e '0" , Vo" start connC<'tion setup wiIh a ri<ing ed ge on th<" REQ paramelcr. ,"'hile the job is running, BUSY = " 1 _ The j ob has been s"cccssfully completed when BUSY "0'\ DO"'IE ~ " I " and ERROR - "0'. If the j ob contains errors, BUSY - "0, DONE - "0" and ERROR - " 1_ The error is then specified at the STATUS parame ter. BUSY. DONE and ER, ROR are reset to 0 when REQ is re rumed to "0 "

Wh ile the j ob is running, BUSY = "I " . The job has been ,uccessfully comp leted when BUSY ~ 0". DO NE - "I" and ERROR ~ "0". If the job conta ins errors, BUSY - "0. DO'KE - "0 and ERROR - "1". The error is then specified at the STATUS parameter_ BUSY, DONE and ERROR are rese t to "0 when REQ is returned to " 0". lTDT 65 TCON PAR Structure of the connecti on data The user-de tlned data ty pe UDT 65 TCON_ PAR contains the structure of the connection data either for the commun ication connection to the partn er device (protocols TCP native and ISO-on -TCP) or for the conntttion to the comm unication layer o f the local operating system (UOP protocol) , Vou require a data block w im this structure for each cOlluection . For each connection. yoo ~at1 use your own global data block b ased on the UDT. or y ou ean combine the data blocks in a sh ared global data block. The assignment of the variables depends on the protoc ol and the devices use d (see Online Help o f STEP 7)_ UDTs with differen t defaults are stored in the library: UOT > UDT > UDT > UDT > UDT > UDT > UDT
0

651: for TCp a cti ve 652: for TCP passive 653 , for ISO-on-TCP active 63 4 : for ISO-on-Tep passivc 655: for ISO-on-T CP active with CP 656 ' for ISO_on_ TCP passive with Cl' 657: for open UDP local

'"

20.8.3 Oa'a runder " -ith Tel' n.th'e or ISO...,n.TCI' The following function bl""'ks a.., available to you for data lrarufor Wiln Ihe connec:lion-on_ emed protocol' Te l' nati>'e and ISO-on- Tel':
to-

connection data. You can specify the ~nd trUlllbo~ with Iht pointer allhe DATA parameter.

In the innial Siale. Ihe parsrneten; REO, BUSY.


Dm,E and ERROR ha,'c signal state '-Q'" Stan the data IllUlSfer ,,-jth a nsinll edge on the REQ parnmeter. On the initial call wllh ~ 1 ",lhe dala is fetched from !he aTea specified with the DATA panl!n~ter. The number of bytes <pCCificdat the LEN param~tcr IS Sent. Their maximum number depends on th-e c<>DI>e<:lion !)'pC:

Fa 63 TSEND
Send data with loile c:onntion Receiw data "~th loiic
c:onn~

> FB64TRCV
You c~n find the paramelt., of tnis function blocks in Table 20.26

You have to establish tnc connection to the panIlCT station with FB 6S TeON ~fOR Irnnsftrring the data (see Chapter 20.8.2, "Establishing and clearing down connections'). Data can b<> eJ<changcd simultaneously in both dtrt'C1ioos ovcr the connection with FB 63 TSEND and fB 64 TRCV.
FR 63 TSEND

Send d.ta " 'it h 10llit <oonutlon


The function bl""''' FB 63 TSEND ~nds data with the prolOCols Tel' n.th~ or ISO on Tel' via an existillil communication conn~ction. You can designate the communication c~_ tion by u,igning the If) parametcr, The specif,_ cation must ag= ""h the variable id in the

While tht job!J running, B USY - "1". The j ob h-IIlI bttn 5U~ccssfull) eompleted ,,"hen BUSY ~ '-Q"'. OOl'o.'E ~ .. , ., and ERROR - '-Q" , If the job routairu TOn;. BUSY - "0". DO'IE" ''0'' and ERROR ~ MI". "fh<, error is then spified at the STATUS parameter. BUSY. DOl\E and ERROR In ..,.,,,t 10 "1)" when RJ::O is returned to
"1)" ,

The data in .he send ana can then be modified allain when either OO:>lE Of ERROR ha. signal 'tate "1".

,-Tabl~
~Q

20 26 Pamnc1 ..... fur FB 63 TSEND&Dd FB 64 TltCV .

with FB

DllIlarion
""'-~

Data I)'po:

"" rn
LEN

00""' ,UR
BUSY
[RROR ST...TUS
RCVP_LEN

DATA

BOO, " . " ,,.,"' '00' " ,m " IIIIIfIina BOO' " . ""'" BOO, " " ""'" -," " IN_OUT

.. . .. .. .. ..

INPUT

(:""'''''10, Lksc:riptiucl S...,., data transfer ( ..ilh n5m, cdll") FIl rudy 10 r~c<i, . (with "1")

WORD

Rc(oemu,,, LO <omttt,llticabon c:oon.<Iloo


10 b. ><111 Of

1r-.'1'UT

l'umi:>er o(b)~.,

r=i"t<j

OUIT",

OUTPUT OUTPUT OUTPUT

Job ("OM) or .~"'Ul"" without mwt (MI") Sob runninll (""OM or oomplmd (~ l i ) Job being P""'~ ("I "') or has been oomplotM ("'0") Error 0C'C\IrTt<I (&t -I i Job <tatus. tmJr iJtfonnalion in tho .au of ERROR " S\lmh<!- ofbyte< ICI'IIlIlly r... i,-t<j SCIId Qf ~ei'-o mailbox

OUTPUT

WORD
~,

0",""

Al'.'Y

20 Main Program With each s"bseq"~nt cali, another data blo<:k is received In format;"n ab""t the length anJ end ofa mes_

F1l64 TRey

Recc;,'e datA "ilh logle c()nncction


The function block FB 64 TRCV receives data w ith the prolocols TCP nalive or ISO on Tep vi a an exiSling communication conn=tion , Designate the communication connection by assigning the 10 parameter. The spec ification mu.<I agree with the vari able id in the connC~ tion data , Spcdfy the receive mailbox with the pointer at the DATA paramctcr,
If the LEN pan/meIe r has 0, th ~
I~nglh sp~cified

sage mme is sent with the protocol ISO-on


TCf'. If LEN at the receive mai lbox is largcr than at the send mailbox. the Sent data are received, KDR is set to " I ", Md the number ofrece ived bytes is " ritten in RCVD _ LEI'. If LEN is ,mailer. an error mes.age is issucd: ERRO R - "1 ". STA11JS - W#IMg08 8.

in the DATA pamme t~r is used. Alief a data b lock has been receiv ed. the numb"r of bytes receivcJ is made a,'ailable on the RCVD_ LEN parameter, and KDR is set t" s ignal sta te "I". With t~C protocol Tep "mive, neither the length of the mess.agc mme nor its stal1 or enJ are transferred , So that the number of bytes sent i, correctly received, the LEN parnmetcr at the fCceive mailbox must be assigned the ~ame value as the L[,~ parameter at the send mailbox If a larger value Ims becn sele~ted for th~ LEN at the recci,'e mailbox, part of the fo llowing message frame (from th~ nc"t job) w ill a l,o be recciv eJ, NDR is only set to "1" when the pa ram eterized length has IX;<:n ",ached. If a smalk-r value ha< been se lected for LEN, NDR is s<:t to "I" when the parameterized kngth is reachcJ, anJ the RCVD _LEN p arameter is "ssi~.'ned the number of received bytes .

FB 64 TRey only receive. d ata when the EN_ R parameter ~"S signal state "I" . While the job is ru""ing. B US Y The job has be~"I1 succc>sfully completed when BUSY '"{)"'. ND R - .')"' and ERROR - "0". Ifthcjob contains errors. BUSY - "0". NOR - "'0" and FR ROR - "' 1", The error i, thcn spccifi ed at Ihe STATUS parameter. BUSY, NOR and ERROR are reset to "0" when EN R is returned to "0", The data in the rcceive mailbox is consistent when NDR has signal ,'atc " I " .

"'"'0

20 .1\.4 Data tra ns fer with UDP T he foll"w iT1g blocks are avai lable to you for data transfer with the connectionlcss UDP pro-

10col.
>

FB 67 TUSEND Send data w ith UD P

Ta ble 20.27 Parameters for FB 67 TUSEND and FB 68 TURCV fa"mt"te!":> "ith I'B

"0
1\'_

m
I.EN

" '"
" '" " '" " '" . " " " " "
.

Deebration TNPUT TNPUT

Data tYJ>'-'

,om
,om
WORD INT

! Con'=';, Do'criplion

..

""<IT ""<IT
OUTPUT OUTPUT OUTPUT OUTPUT OUTPUT
OOTI'UT Th'_OUT JK OUT

DONE
~,

BUSY ERROR STATUS RCVD LEN DATA ADDR

'OOC BOOC BOO'


BOO'

wo=

Start data tnlnSfer (with rising cd g~) FE roady to rcc~ i " e (with"l '") R~fcr=ce to the communication point Number ofb;~cs '0 be .on' or received Jot> runni ng (,il") or executed without erro,. (" t .. ) Jot> running (,,0") or completed C'l >0) Job being proces;;ed (" I '") or has been completed ("0") Enor occurred (at "' I ") Job stanIS. crTor information in the ca<e of eRROR "l ~

'" " '" " '"

""

A~

ANY

"lumber (}f b)1~' actually re<:eived Send or =eivc mailbox Pointer to the add .. " of 'he ,ender Of receiver

'"

20.8 IE cOllllDWlieation

~
~

FB 6STIJRCV R<;:<:el~e data with UDP

Uf)T 66 TADD_ PAR Data ~trucrnre for th e partnor address

"0'. DONE - .. ,'. and ERROR ...'0", If the job contalll$ cnoT'S, BUSY '" .'0", DONE " ''0'" and ER ROR .. .. \ ... Theerror is then 'peci fied at the , STATt:S rarametcr, BUS Y DONE lind ER ROR I\fC re,etto "0" wh~n REO is returned to

Table 20 ,27 shows the pa ramete~ 'Jf the function blocks, and Table 20,28 lihow~ the .truetun,: OrlM UDT
Yw ha~e to establish" C01U1lIon to the communication layer of the openlling system wilh fB 6S TCON before UVlsfeninll the data (see ChKpt.". 20.8 ,2, "Establishin8 and clearing down oonnlio",'I, The K,Jdress of Ihe COlD_ munication partner is located in a data area Ihat h~, the ,tru~t "r.: uf UDT 66 TADf) _PAR,

"0" ,
The ([,ata in the send area can then be moditied again ",'hen either DONE or ERROR has signal state ,'.

fB68T URCV R~~~IH dlllM wilh UDP


The function block FE 68 TU Re V receives data with the UDP prut<><:ol. The assignment of the I[) parltmeter designates the conDcction between the U$CT proaram and the communication layer of the openoting s)",tern. The ,'alne must ai:f'X' with tbe variahle iJ in the eOllIlCClion dsla. Specif)' tile receive mailbc.>x "'~Ih tbe pointer at the DATA fl'll'aDX'-

.. B 67 TUSl:"D Se nd data wi th UDP


The function block FB 67 TUSEND ..,nds data with the UDP prumco!.

The assillI\ment or the 10 parameter dcsillI\lltcs


Ih e connect ion betw""n the user program and the communication layer of the operating 'y'_ tem, The value must agree with the variable id in the con nection data , Specify the scnd mail. bo~ with the pointer 3tthe DATA parameter, The informatioD on the commuDicatioD parmer is located iD. data area to ,.,h ich the poinler al the ADDR panu:nctcr poinlS, With eacb new $end job, the addr<:ss and thus the panner can be changed without havina to redefine the commUDicalion aCCess point with FB 65 TeON,

'cr.
The infonnation On the communicatlDD partner is located in a data area!O wtti~h the pointer a, the ADON. parumeter points, The number of bytes to be rece ived i, oct at the LEN parameter ( I to max. 1,460), After a data block ba" been received, the number of bytes recehed IS made available on the RCVD_LEN pllnometCT, and NDR i. 5eltO signal stale " I', Data is only received wben the EN R parame tel' has signal stale "1'", While the job is running, BUSY _ "I", The job has \'Iccn succnsfully completed whl'D BUSY " "0", NOR ,," I" and ERRO R " "0", Ir the job contains ('TY()1'5, BUSY" "0", NDR" ''O~ and ERROR " '1 n , The C1T\)I' is then $pifted at the STATUS parameter, BUSY, NDR and ERROR .n: n:,;el to ''0'' wben ES R is returned to ''O~, The data in the =-~ivt\ area is NDR hu signal state "I",
consi~leDl

In the initial . tatc.the parameters REQ, BUSY, DONE aDd ERROR have signnl "tate "0", Stan data tr.n.fcr with a rising edge on the REQ pa.
rtlmo:to:r, On the initial call with ",.', the data i\ fetched from the area ipe:cilied witb the DATA parameter. Thenumbero f bytes ~cificd at the LEI\ pan.mctcr ill sent (I to mu, 1,460),

While ,he job is runnina, BUSY " ."'" The job hal bn snccessfully oomplcted when BLSY -

wbm

3"

20 Main Program

UD P (User Data Protocol)


Connection bUlldup is nol camed out with UDP. The communication partner is spc~ified at the ADOR parameter of the send b loc k (IP address and 1'011 number). The receive block .hen supplies th~ (I' address and the pol1 mun ber of the sender at the ADDR parame'er. The user-defined data type UDT 66 TADD_ PAR contains lhe struC.ure of the address infor mation. The pointer at ADDR points to 3 da,a arca with this structure . W ith UDP. information on the length Bnd end of a message frame i~ tran"f~ITed. [fLEN at the n; ~eive mailbox is larger, the sent data i, copied to the receive mailbox. NDR is Set 10 " 1"", and the number of received bytes is written in RCVD_LEN. If LEN is smaller, an error meso sage is issued: ERROR - " 1". STATUS W#16#8088 .

20.9 PtP communication

with S7-300C
20.9.1 Fnn d amelUal. \\'hcn u,ing point -IO-point communicanon (PtP), you transmit data over a .crial interface 10 a communications partner. e.g. a printer or a SIMATIC $5 station. With cena;n S7300 compact CPUs, an RS 4 22/485 imerface (X,27) is alre ady int egrated. The communications connections arc specified using the Hardware Configuration tool when parameterizing the CPU's imerface properties . ASCII mode , the 3964(R) procedure and the RK512 computer coupling arc avai lable as transmission protocols . The communications function, are system function b l ocks $FB wh ich are integrated in the operating system of the S7.300C CPu. The instance data blocks for these SFBs are present in the user memory. The SFBs do not test the parameters . if parameters are set incorrectly, it may occur that the CPU goes to STOP. If you USe the u-ansmi ssion protocol of the computer coupling. " synchroni>:ation dala block ;s addi tionally us~d (once for all computer coupling SFB, in the user memory. Figu re 20.28).

UDT 66 TADD _PAR Data s tructure ufthe PQrtner addre ..


UDT 66 contains the stru~ture o f the panner address in the ~a'e of transfer with the UD P protocoL The ADDR parameter at the funct ion blocks FB 67 TUSEND and FB 68 TURC V points to a data area with th is stru~rurc

S.nd or eUent statton UMI, program", the CPU


ASCII dr-Iv., "" 3~0!4R: No SFS.,.. ' in the ~ ... r prog,am .,.,..,uo,..... Iranofe,.

:J

.,. -~ ==~;" _ 1 _ I~'


__ .... -.--Joo ",.
- ,,"

Recetver statton or serv.r ... Uon CPU Use< p"""am In tn. CPU
<><-otino
.,....."

"""trot. ,n. " . n.f ....


S:l

ASCII (1,iyw or 3!<0!4R: An SF6 <oil "' ]h. u.er PfOIII'Im B

~".- i----< ~ -.,..


-"""'-

~-

An SFa "-",, in In.

RK~12:

" -,';:':' E :J
a lso required.

In. "ansfe,. A

.ynchroni='' ' DB i.

~_ p~ram

conlrol.

~ ~:J . ~

'~I -

Fla;:urc 20.2H Point.to .point Connection with S7300c

",

Cun fl~"rlnII'tP
u~

commun;cy!lo n

lO.!U ASCn driver and 3\164(R) I,n)<ed " ,.., You can send and ,..,ce iv~ dala v,a the poinl-Iopoint cQnn~~lio n wh~n usinS Ihe ASC I1 driver or Ih~ J964(R) procedure_ The following system function b locks are requll"<'d ;
:>

Conf'gurntion tool to set the Irnn~mis~ion pro\o<;ol in Ihc prop<.:r1ics windo'" of the poinHo-poinl interface:
Ihe
H~rdware

I>

ASCII mode

'f'he data are mmsmined as AS('U charneI~, The Ilanlimis>;ion is nOI acknowledged_ Sening ohignalassii'UJlC1llS and tnln'lmis-$ion parameters ~uch as baud rate. parity.
endof-Ie"t characler.
t>

SF13 60 SEND PTP Send data "~th ASCn drive!" or 3964(R) pro<.:edu,.., SF13 61 KCV_PTP Rec~ivc dala with ASCII procedure
driv~'"

(>

or J%4(R)

39 64 (R) pro<:wut'C The data arc SCn! to the communications punnC'!", and positively ncknowledged by Ihi$ when recrived corr:dy. Setting of signal liS,ignment'l and tnlIl~missioD patamc_ lent ~och as baud rale. parily, block cheek.

po

SF B 62 RES_RevS
Dekle re,eive buITer with ASCli driver or 3964(R) procedure

Table 20.29 ~bo"", the parameten Or!Moe system function bloch_


s~'n 60 S EN O]TP

po

RKSI2 computer coupling D;ol& tnln5mission can be coordinaled by socalled ~ommun icatinn nag~. Data ree .. ipt und th~ retching of dat a are acknowledged. Setting of signa l assignments and transmis.ion paralJ1clcr;; such aj baud .... ,~, panty. block cheek_

Send d"t~ .. llh ASCIl driver or 3\164R prundure


The iystem function blo<:k. srn 60 S E N\}_ PTP is u'~'(1 to send a data area 10 communication~ panner. Use th .. Hanlware Configunotoon tool 10 oct the transmission protOC<l I and th .. transminion panometCl"$. Specify Ihe area of dala to he tnlnsmil1e<i using the SD_ I parameter. The length of the InInsmined data Mea depends on the interface parameters. c.g .

Wilh The 3964(R) and RKSI2 lransmi~.ion protocoill, the communication, pouners must have <lirr~-renl priorities in order 10 ddine lhe sequence when ,..,quests tn transmit .'" sent imu '''mcous 1 y.

,-~

I"r=<:n. in SFB
W

Da:la..n",,,

"0

IN_R

LAJ)OR

00"
!IIDK ERROR

" " '" ." '"


W

"

" . " " . "

I"PUT
"'~u<

no,,, ""'"
",X>c

Data Typ.:- CQDICUt5, Oescripli"" Tnii<'" job ,,~th 5ianal taI ... Ml M

Reccl"e CDlIblc
J". With M ,he job i,
.bor1~

TNl'tif
INPUT OUTP UT OUTPUT

WORD

Submodule odd",,,, of int",face

ROO'
DUO!.

STATUS SDMi ROM]

<EN

'" " " '" " " - ., " -"


W

Olm'u<
OUTPUT INM OUT INMOUT

WORD A'<Y
Al'-'Y

""'"
lNT

Wi,h hi". 'he joh ;' .. ill ",,,,' ina Wilh "' ]" . lIle job bas bc:-cn cumpl<'tod ",;,h oot fauh With Min rault ba< oooun-ed
Error inf<>rmarinn

Send mailbox Recci,c lIilIilboA


Numbcr of fran<mmod bytC5

TN_OUT

20 Main Proaram send up 10 lenglh specified by Ibe LEN panlmclef, or send up 10 an end-of-text cbanlcter, With the ASCII driver, you can send lelellnlms up to a length of 1024 hytes. SFB 60 SE~D_ PTP trnnsmils thc data in co""iSlenl blQCk. of 206 bytes, You mu.t n01 change Ihe data in the ~end Brea while the trunsmission i. runninll' Sending is triggered by a tisinll .ignal edat' on the REQ parameler. Wilh signalJ .tatu~ " I" on the DONE parameter, the SFB signals llml the job has bc<:n compleled succenfully. In the event of an elTOI, the ERROR p"",mcter is SCI 10 "I" and the error information OUtpUI in Ihe STATUS parameter. You ea" abon a ClltTent send job by meanS of sign.1 statU! " I " on the R pa",meter, and reset Ihe call instance to the basic state. S,,'8 61 RCV_PT P R eceIve d AIA wll h ASCIJ drin r O) r J964R pr O)(cd urc The system function block SFl:l151 RCV_?TP ;s used to rece;vc a d ata arca from a communi. cati",,~ partner. Usc the Hardwarc Coniiguration tool to set the transmission prOlQCol and the InlnSm;58ion paramelCTS. The received d". ate enle~d into the ~a spedficd by the RD_I parame .... , The numbel- of received byles is T pnsenl in the LEN paramcter. S1"'13 6 1 ReV _PTl' recdves the wna in conslslenl bloch of 206 bytes. You must nOt aceus thc dalll in the receive a~a while the transmission is ronning. The CPU's ;\1!cmal receive buffer has a size of 2048 byles, In the parameter sell;nas of th~ interfnce, you can al.o define whether you wish to u~e the complete length oflhe reccive buffer for data rece ipt or 10 limit Ihe nuruber of r .. ...,eived tcle~m.'I. A aignal Slatus "l~ on th<; FN_R pommeter ernobles d!l1J, rcce;pl. The "'DR pammelCT has a signal statu!> -I" ifnew da1J, have been receIved 5~es;sfully. In the event of an error, the ERROR panlmete, ;8 SCt 10 'T' and Ihe CTTOI" infonnation OIJIpUl in the STA11JS parameter. You can abon a eUITCIII send job by meanS o f signnl status "." on the R parameler, and re~el the call instance to the basic state. S I-' R liZ RES_R eVB Dele te r~h"e b uff" r ... ilh 3964R proeed u n

"scn d rl n

r or

System function block SfS 62 RES_RCVIl dektes the receive buffer of Ihe point-to-point ;merfa"e. A telegram received during the delele operation i , exempted from this. Deleting is trigg~Ted by the <isin!! sill"al edge on the R E;Q Jl'in>meter. Wilh ~ilOIlUI status "I" on tM DONE parameter. the SI'B signals thai deleting """ succe5sful. In Ihe event of an error, the ERROR parumeler i. SL1 to "I~ and the error informalion output in the STATUS pammetCT, OOKE. ERROR and STATUSareonlyset forone call at a time. You can abon a eUtTent send job by mcans of signal starus hl_ on Ihe R p.rametCf. and reset the call instance 10 Ihc bIosic state. 20,9. 3 RKS I2 cornp ultr couplinll With the point_to_point conneclion, you Can send and rc.:eive data wuh applicalion of Ihe RIO 12 computer coupling. The syStem function blocks required for thi, bre:
:> :>

S FB 63 SEr-'D_RK Send data with RJ(j 12 compuler eoupl;nll SF Il 64 FETC H_RK FCich data with RI(j 12 comp uter coupling

.. SFB 155 SERVE_RK Rccei~'e data and make available wilh RK512 cOmputeI coupling Table 20.30 shows the pammelers of these I~m fun<.:!ion hlQCu .
Sp~clnc atl o" ~y"_

of t ran sm lulon . r r.

SFB 63 SEND_RK sends from the area specified by SO_I, and addrencs a data block area in the partner device. SFB 64 FETCH RK can access all address areas in the partner device. and S10Ies the fetcbed dala in Ihe data block atea specified by the R D_ I pammett'1', 5FB M SERVE_RK can saVe received data in a data block, and make daa available from all address areas. The pcnnissible u$;pmcms for the parameters are li.led in T"ble 20.31. Certain values.re only meaningful in conjunction with a SIMATIC S5 slation as Ihc pnnner device.

""

20.9 PH' communication ",;th S7_)OOC

Table 20 .311

,>

63

64

CPU

>,

SyncllronualloD data block The system function blocks ofthecomput~r coupling work together with a .ynchronization data b lock in addit;"n to the in,tance data block, and thi' ,}nchronizes and comrols Ihc activities of all "ompulcr coupling instances. The synch roniza_ tion data b lock is present on"" in the user memory. You ,hould create ;1 as a global data b lock with a minimum Jengm of 24(J bytes. Ent<:r Lite number of the data block in th~ SYNC_DB parameter.
Coordination with communication flags

address area F. Use a communication flag for each transmis sion job, and specify it. addres' in the R_CF _BYT and R_CF_ BIT orL_CF_ BYT and L_ CF _ BIT parameters. Iflhe local CPU is the client, the system func ti on block SFB 63 SEND RK i. used to <end data and SFB 64 FETCH RK to fetch data. Wh~n sending and fetching dnta from the partn~r CPU, the address o f the communication flag i8 also included. Ifthi. communication /lag in the part oer CPC has the signal ,tatuS '"0", the partn~r CPU permits importing of the dala package inlo the uSer memory in the ca.C of a send job, and reading of the data pa~bge from th~ u,er memory in the case ofa felCh job. Tbe communi~ation nag is then set by the commu-

Rf"<:eipt of dat~ using the computer coupting can be coordinated by eommun ieatwn flags. A communication flag is a b it from the flag

'"

20 Main Program
Tabl~

20 JJ Specification of Transmission A ",a

Pamtt.l>w;,' 'j ,

,
,

7:i1JC;

...

SFB 6J
S,nd da",

SI'Il64
f<'" b u. ...

- CPU

m.
C~

0104

Oto 4

I
D

SFBM
~elT'

'SFB 65
Pt<,..Wo.n "f Jot"

.\1<aning

"

~,

D.X

D,X.M , E.A, T. C

U M, A. U

TY P!:',

CHAR

c,

, ,

DB}"O DBl--'O R OFFSET

INT INT

o to 255

o to 255

m'
~

Ot051O
I)

to n

I to n

>inglo_pTOec,"O!" mod~ 0 num""r of CPU in multiprocessor mooo D ~ d,ra blod. DB X - exte nded dala block [)X ,1 _ fla~ memory "c~a E - pmce image of inputs A " proce,s iTIUl~~ of output> T - t im er valoes Z - counter val"e. K umber of dal<O block (irre levant with M, E. 1>., T and L)

,-

.-

0 105 10

,_

OFFSET

10 2S!

Otol024

Ot01 024

First byte with data block, (m u", be an e' -en add",,,) f ir;l byte w ith M, F. A, T . ndZ T d~l"nm length

CPU-,peclli c

nications fimction to ind icate lhal lhe dala rransm is"ion ha..; tak en place_ The data can lhen be edited or preprocessed by the user program_ !f th ~ communication n~g is reSet by lhe u.er program. lhe data transmission is (:nah led again. The conilllllIli~ation flag in the partner CPU therefore p<:rrn il' control o f d ata transmis . ion_

partner_ Cse t.ne Hardware Configuralion too l to s~ t!he transmission p mloco l an d (h e transm is sion parameters _ S]X~ify the data arc" tu be sent in the SD , p arameter. Enter th e length of lhe ,en! dat a area in the LEK parameter. Note lh m the number o f bytes must be e,'en. SfB 63 SEKD_RK only l"'~n'mj" the data if the commu nica tion nag in the communications partner h.." the signal starn, "0'" _A Ie!cgram can be up 10 ]024 by tes long, The <lam are transm itted in COns iSlent blueks of 128 bytes . You mo,t !lot change the data in lhe send ar<:a while a tmnsmiss ion is laki n g p la~c. Sending is triggered hy lhe rising s ignal edge on lhe R E Q param etcr. W ith signa! statu., ") "' on the OONE pammeter, {he SFB signal> that thc joh was comp!ek"(\ ,u~~c,"ful!y. In the event of an ~rror, the ERROR param~ {~ is set to '", .. and -r (he e tTOr infonna{ion 01ltput in the STATUS parameter_ YOll ean abo rt a CUTTent send j ob by me ans of "ignal statos " )"' on lh e R pammet~.,., and reset {h~ call instance to th~ basic stale _

if lhe !()C s! CPU is the s~rver, the dSla a...., received by SFB 65 SERVE_ RK it rhe client sends data, or made available if the clicnt fetches data. On lhe SfB, param~t erize lhe loca l cOmmunicalion nag (in the ,erver) with which you then control the rece ipt or provi;; ion of data in the uSer pro!lf'lIIl. The SFB indicates in t!1c L_ CF_ BYT and L_ CF BIT pacamclcrs w hich conmmnication flag is used for the CUIccnt ly exe~ uled job and has becn set to '" I '" . t'o llowing processing of the data (fetching or p rovision again), reset the commun ication fl ag by the program, lhns enabling processing of Ih(." n=l transmission job.
SFB63S F.:'W _ RK Send dara with RK512 computer coupling Thc system funct ion block SFB 63 SbNU RK is used to sen d a data arca to a commu nications

350

20.10 Configunotion io RUN

SFB 64 F"ETCH_RK
}<'1.'tch d"t& with the RK 5 12 co mputer eou_
]>lIn~

tnllIsmission is oontroUed by u communicalion


flag in Ihe U5er program.

The

!iy~teIll function block SF8 64 FETOi_ RK is used to fetch a data. area from u commu -

nications parmer. U.e the Hardwan: Configu rallon tool to set the tran smiSSion protocol and the transmission parumetC1"S. The fetched data are entered into the a...,a specilied by the RD_ I parameter. The number of received b)1e; is pres~.., t in Ihe LEN pammeter. SFI:I64 FETCH_RK ,,,,Iy fe tches the data if the communication flag in the communications pannCf has the si gnal SI~tuS '""0". A telegram can be up 10 1024 bytes long. The data are transmit_ ted in oons;stCflt bl""'ks of 12g bytes. You must nOI change the dalB in the !II:Rd area while a transmlnion is taking place. You cnobk the fetching of data by means of,ignul5taWS "1" in the EN_R ]lnram ~tcr. Si~ 'llal .t8lU~ "1" in the NDR p urameter indicales Ihal new data have been fetched liuccessfu ll y. In the event of an error, Ihe ERRO R parameter is sct to " 1" anod the error infonnulion output in L;,e STATUS parameter. You can aborr a cur...,111 fetCh job by m ..ans of signalstatuB '-In on Ihe R PMramcte . and fe.el Ihe e~ll instance 10 the buic stue. SFB 65 SERVE_RK Rfef lvf datA ~nd mRk~ M~ M l1Mh lc with the RK512 c"mputer c"upllng The system function bk>ck Sfl:l6S SERVE_RK hili the server functionality fOT the RJ(5 12 com puler coupling. II accepts I dati an::a sent by " eommunic",ion~ pal1 ner. and makes B data lITell available "'hi eh is felched by a eommuoieation ~ !lartner. TIle received dUln, or data made avai lable. are entered in lO the area specified by the L TYPE. L DBNO und L OFFSET paramel.. rlI. The nu--;"bcr o f lrensmir.c:d byte, is present in the LEC<>I paramcl~'T. SFlJ 6S SERVE_RK Iransmii5 the data in consislent bl"",,,", of 128 byte~. You must not aeees. Ihe data in the mtnsmission area while a tranSmi~sion i~ taking place. Coordination o f d~ta

You cnuble process ing of Ihe job by sign al staNS "j" in th .. nCR parumctcr. Signal Stat"s "1" in Ihe NOR parameter indi~Bu,s that new da\.a have been ""cces~fully rec .. i,ed o r fetched. In the event of an error, !be ERROR pan.metc:r ;5 Se1to "1 ~ and lbe error in fonnation ourput in the STATUS parametc:r.
You
~un

abon a current job by m .. ans of signal


p~r~mctcr.

Slatu~

'"]"' on the R

Imd resel th e

call instanc e to the basic state.

20.10 C onfiguration In R UN
Confiiuration in RUN (CiR) means that chanlles to the system can be made dwing operation. Thi. functionality permits you to change Il,e configurat ion o f the dislrib tncd I/O of an S7-400 station Wilhout Ihe CPU enlering STOP or hll ving to be .et to STOP. The ]"IO~ible chang~..,. induOc the add ition of compaCt DP sla\',,'<, ET200M !>l8tions and PA master SY$tcms to an exi~tinll Dr ma~"1"r systc:m. Ihe addilion of modules 10 T200M ~lB_ rion . tmd the addilion of PA slaves (fiel d d~vlces) to exisling PA master ~y"em'. All objecls adder! d uring runtime ean also be removed all" in (Figure 20.29).
Pr..requtsites and hmJlalions Clt,st ill add1l101l to th.. faCI that all involved devices must be able to handle Ihe CiR funcrionalny. For example. Ihe PROFIBUS OP m3SlcrsyslClO must be 8 mOnoll\II,tet" sylilem and musl nOI cxhibit constant bus cycle times, tbe useofintelligetu DP .laves is nol p.. rmi .,iblc in the !lSSOdUled stal'nn co,nponents, and the module paramctent must be saved on Ihe C PU.

Component., ""Ih and withoul Cil{ fu nct io nality can be mixed: however. changes are only possible on componentS wilh CiR capabil ily.
During n.-con.figumtiOlL processing is mtcrrupto..i for a dton period (typically 1 liI, can be progranli1lW). The time can be kCJlI short if only a
f~"W

change>; /Ire alway. came<!

QUt.

'"

20 Main Program

Configurat ion in RUN (CiR) is possible for .e,'eral DP mastcr <ySlL-rrl" PA master s ystems and lOT 200M stations,

Place holder for subsequently added OP sla,-. , (contains the mal[, numbor of a,lditional slaves and the uppcr limits of the additional uSer data volume) module Place holder for subsequL..,lly added modules (oontain, the uppcr limits of the additional u'er ,bta ,'olume)
DPIPA

coupl" ,

",,",,,,,",,,,1 dovic..$)
Pboe holder for subsequently added PA slaves (c{mtain< the max, !t umber of a,lditional field devices and the upper lim its of the additionalll!icr data volume)

20.10.1 P rep a r ation o'-Changes I" Configuration ConfiguTC an S7-400 station (CPU w ith [lIllI' ware release V3.1 or later) with at least one PROFIBUS DI' master system using the Hard, ware Configuration tool. Then add the Ill' slaves and - ifcnvisagcd the dunilllY valn .. s fnr later system expam ion (CiR object under PROF IBUS DI' in the hardware cBtBlog) , Set the later ma}<ltnum eonjjguration in the propertie., of this dnmmy value. The Hardware Configuration tool cale(llate. 244 input bytes :md 244 ,"'tput bytes for each additional DP s la,-c_ In reality, far fewer (lSeI' data are nsnaHy J"Cquired, You can change thc IOtal of all

required input and output bytes by c licking the control box "Enhanced selling ''',

y,,,, Can also provide srace in an ET200M station for later expansions . Add a station with an imerface module JM I 53-2BAOO-OXBO or better to the DP mastor system, and acti vate the checkbox "Module replaeemem during runt_ imc" on t.he "Special" lab in the propertics of the station, The active bus modules r.. quired to caoy out Ihe mOdule replacements are d is played ill the boltom window area (they are required Tor the mechanica l de.<ign. but are nOl configured ). It i. recotn m~n dablc to fit the ET200Jl.-l stmiDn with active bus modul es up to

20. I 0 Confil"",tion in RUN

Inc p lanned configurnlion since Ihey must nOt be ;n""ned or removed during nmumc. You ean now insert modules into the EnOO~1 station and - if you wish to carry OUI laler upamiolL'l ~Iso a dummy dire<;tly following lIlc las. configured module (the objt CiR mod,"e under the used 1M 153 in Ihe hardware cata log). Set the required number of additional input and OUlPUI byles in the properties of the CiR module. If you wish to "-"tend a PA mastcr system connted to tbe OP mastef:lystan. ust an 1M OAA82-OXAO or better .... hc OP/PA link. A dummy i, also provided for lhi$ for subsequent e"pansion wilh field devices (CoR objl!C/ under the used 1M I ~7 in Ihe hardware ealaIoa). SCI lhe required number of additional InpUt and OIltput bytes in the propoenies of tbe Ci R module. With the CiR-capable 01' master syStem marleed and by using EDIT ..... ?>1ASTER SYST"-" ~ ENABLE CIR CAPABILITY, a CiR object is aencrnled on the DP master syStCfIt and on every subordinate PA master ~yslem with CiR capability. A CiR module is insened InIO each ETIOOM statton with CiR capability. All CiR objts and CiR modules an: deleted -.gain using EDIT ..... MASTER SySTEM ..... DISAIILE OR CAPABlLrrY.

p.

Changing of module parameters in an ET200M station (c.g. n",w or modified assignment to a partial proces, image, activation of previously unused channels)

:> Cancellation ofabo.e-mentioncd modificatiODS (starring at the higllnt Bddre.,..,,; for

modulcs and slaves) The tOl81 of configured (real, immediately used) addres~es IIDd thc addresses for future use must not be g~ater than the quantity frameworX of the DP master <i$ checked durina eOllfigurllli), but em be larger than the quantity framework of the CPU (is only cbecked when convcr1ing' into specific slaves or modules). During a Cdt proc ess, the configuration ~an be on a =imum of 4 DP mastcr syStems. Un<Jer eertain conditions il is recommendable or even essential to carry out the CiR process more than oncc. If, for example. moduleS or ,la\'cs are to be replaced by others, thc coI5J101lding component must be rcmov~"4 first. and the r.-placement added in a second CiR process.
~hanged

n7-

10.10.l Load Con filCuration The (inirial) loading of a configuration with CiR dC11"lenl$ or uith a modified CiR configu_ ration is carried oUl with the CPU in th", STOP statuS. In order 10 ~he<:k whelher the CiR capability is ulw present. you should subs.equemly load Ihe CiR configuration _"lin in RUN. TeslIna for CiR eapo.biloty usinll STATION ..... CHECK CtR COMPATIBILITY is not 100% posSi_ ble omi~. I'or example. the CiR synchronization timc cOIlld be limited by the SFC 104 CiR. To k~ the CPU in the RUN stams during the CiR process. you must make sure Ihat intCTTUpts from unknown components are ignored. A corTCSJIOIldina program mUSt be present in the following organization blocks:
I>

20.1 0.1 C hllnge Co nfigura tion You can DOW ~hanac the confiiUf'llion within lIle limit!; specified in the CiR elements, and load again in RUN . P0$5iblc modifications arc:
I>

Adding of~ompW and modular DP slaves to an e"i,lin& DP master systcm (Ihe added slaves musl have ~ higher PROfl8US address than the largest addrcM previou;;ly used) Otanging of assignment of partial proce.. image with existing DP slavcs Adding of PA slaves (field devices) 10 an ex isting PA mastcr system Adding of DPIPA couplers aftcr an 1M 157 interfu~e module Adding ofDP/PA links indudlOg PA mastCr system 10 an ex;sling DP master syStem Adding of modules to an ET200M station

I>

I>

Process imtmJplS OS 40 to 08 47 Timing error 08 80 DiaanOSlic interrupt Oil 82 Hot swapping interrupt OU 83 Program I!"xurion fault 08 Rack failure 08 86 J,O atC(!5S fault 08 122
8~

I>

I>

I>

, ,

20 Main Program When adding m odules or slaves, you .hould first load the configuration and then th~ matching u.er program . Whcn removing modules and ,laves, lirst load the aJaplcd U'le. program and then lh~ ",od;:fi~"<I contigueat;on. Adding or rcmov ing rea l modul~s or ,Iave.< tm..~t only be carricd out foll"wing loading of UlC modified confi guration (whcn the DlTF LED on the C PU has gone off) _ 'Vilen R-parameterizing modul es you must frrst load a user program which no longer addresse, the ao;.~ociated modules or no longer cvah,ate, their imcrrupts _Then I"ad the moditied c"nfIg uralion, change the hardware if necessary. and lo ad the ul;<.... program a daplcd to the moditica tion_ 20.10.5 Effect. lIO Program Execn tioD ExecUlion of the user program is stopped during tlte CiR synchronization lime . All process images retain thelT lasl va1"",. TIle SlMATIC limer, and Ih e CPU cloci:: continue. Any interrupt'! whi ch occur are only processed al the end of tlte CiR ' yncmonization time_ Communicalion Wilh a connected programming device is limiled; only the STOP conUlland is accepted. Following syn"hroni~alion. th c CPU slarts the organizat.iol1 block all ~o "Timing ~rror" with lhe value W#I6#350A in the firsl word of the ,tatt inronnation (vHriables OB80J'V _CLASS and OBSO_fLT_1D). Tho r~quired CiJ{ syn chronization lime in ms is presenl in the "ariablc OBSO_ ERROR_ INFO. lfmodule. are 10 be repammet~ri / ~d, Ihe CPU lh en slans Ih", organizalion b lock OB S3 "Hot s wapp ing in1~nupt" with the value W1l16#3367 in th~ f,rst word of the sl.art infomlation (varia bles OB83_ EV_CLASS and 013~3_FLr_ m). The rnodul~, are subseqn ently reparameterized_ It ca ll occur that the a>soc iatcd modules do nol deliv er va lid vall'CS in the meamim". Follow in g rcpa.rameterization, lhe CP U starts II", all 83 again, lhis tim~ with W~ 16#3267 in lhe flI SI wwd of the ~Iart in formation. FauUy reparameterization is signaled by \\'# 16#3968. Th ~ associated modules arc Ihcn cons idered as not avail<,ble. The d<:s~ri bed proc edure; s execUl ed in cach maslcr 'ystem which is affected.

20.10.4 CiR Syn chroni:tRtioD Time


FoU"wing load ing of the new configuration imo lhc CPU, the new data are checked and imp<ln~d ;IItO th e curren t configuration if corteet. This importing requires a c~ 'r\ain time. lhe so--called CiR syncbroni:tati"n tim;: Process execution is inK-rrupted during lhis period. The CiR synchroni:talion time is calculal<:d from the total of the Cil{ s yn~hronization times of aU UP and Pi\. mast~r systems iml, lved. The synchronization time for a ma, ter system de p"nds on the CPU used and on the real and p lanned VO volumes in lhis masICt system. This time is indk ate<j by the HmdWaJ'C Contlguralion 1001 in the prop~rtics of the eiK object in th~ master syslem. The WOTSI case is always calcula1~d, so thai the acmal CiR ,<ynchronvatioll lime is ,hon~r. The 'Y"chronization limC is lOOms if only mod"le< are rcparameteri:ted_ The CPL' compares the ca lculated C iR synchronization lime w ilh the p~-nnissibk upper limit , whos~ default setting is 1000 m . Yo"ean cha nge thi, "prer limit l.I,ing the Sl'C 104 CIR If Ihe calcu la ted CiR synchroni7.ation time is gn;ate r lhan this upper limit, lhe ~hange in configurat ion is nol carried out .

20 .10.6 Control CiR Process You can use the SFC 104 crn 10 b lock lh~ CiR proce" in th~ us~... program, 10 limit it for a cert~in period. OT 10 enable it . The Sl'C parameter; "rc li.ted in Tnble 20 .32 . MODE ~ B#16#OO deJiv~'l's lh~ eurremly yalid upper limit for the CiR ">~lchron i zntion lim e MOUE - B#16#0 1 _,ets the CiR s)llchronizalion time to the default value 1000 ms anJ e n ables ~x~culion of th~ C iR prnees ._ MOUF D#16#02 lIl1condhi onally d isables the CiR pro<:CS$, MODE ~ 13#16#03 only disables it iflhc C iR synchronization lime calc"laled in the CPU is gr~aKT than Ihal spcci tled in thc FRZ_ TL\1 parameter

354

20.10 Conf,gura.ion in RUN

Tobie 26 ..32 ParameterS of tile SFC 104 CI R

,;
BIII6/!IOO: S "15itIOL I

,""lomIT--tru"'__tiS"I~);

S"I6Kl2,

21 Interrupt Handl ing

21 Interrupt Handling

Intenupt handling is always event-driven. When such an event occurs, the operating system intemlpts scanning of the main program and calls the rouline allocated to this particular eVCllt. \\'hen this routine has executed, the op..'t"ating system resumes scanning of the main program at the point of inte!T'Uption . Such an interruption can take place after every operation (slatement). Applicable events may be interrupts and errors. The order in which vinually simultaneous interrupt events arc handled is regulated by a priority scheduler. Each evcnt has a particular servicing priority. Several interrupt events can be combined into priority classes, Every roUline associated with an interrupt event is written in an organization block in which additional blocks can be called . A higher_prior_ ity event interrupts execUlion of the routine in an organi'~a\ion block with a lowe r priority. You can affect the interruption of a program by high-priority events using system functions.

[>

[>

[>

)0

Hardware interrupt An interrupt from a module, either via an input derived from a proce," signal or gen erated on the module itself DPVl interrupt An interrupt from a PROFTDUS DPVI slave Multiprocessor interrupt An interrupt generated by another CPU in a multiprocessor network Synchronous cycle interrupt An interrupt from a PROFTDUS Dr master synchronous to the DP cycle

Other interrupt evems are the synchronous errors which may occur in conjunction with program scanning and the asynchronous errors, such as diagnostic interrupt' The handling of these events is discussed in 23. "Error Handling", Priorities
An event with a higher priority interrupts a pro-

gram bcing processed with lower priority

21.1 General Remarks


SIMATIC S7 provides the following interrupt events (interrupts j:
[>

Time-of-day interrupt An interrupt generated by the operating system at a speci fic time of day, either once only or periodically Time-delay int errupt An interrupt gl-"Ilerated after a spec ific amount of time has passed; a system function call determines the instant at which this time period begins WatChdog interrupt An interrupt generated by the operating system at periodic intervals

because of another eVent. The main program has the lowest priority (priority class 1j, asynchronous errors the highest (priority class 26), apart from Ihe stan_up routine. Al l other events are in the intervening priority classes. In 57300 systems, the priorit ies arc ftxed; in 57-400 systems. you can change Ihe priorities by parameterizing the CPU accordingly. An overview of all priority classes, together with the default organization blocks for each, is prcsente<\ in Cbapter 3. 1.2, "Priority Classes". Disabling interr up ts The organization blocks for event_driven program scanning can be disabled and enabled w ith system functions SFC 39 DIS_IRT and SFC 40 EN_1RT and delayed and enabled with Chapter 2 I .9, "Handling IntCTYUpt Event, "j.

[>

SFC 41 DIS_AIRT and SFC 42 EN_AIRT (see

356

21.2 Timc-<J f-Day Interrupts

Curr~n '

sign a l . tat e.

In an int~rrup1 handling routine, one of the r,-"<\uircment s is tha' you work with the CU!Tent signal states of the [10 modules (and not with thc signal statcs ofthc inputs Ihat wcrC updated at the start of the main program) and write the fetched signal states direci to Ihe VO (not waiting until the process-image output table is updated at the end orthe main program). In the case of a few inputs and outputs for the internJpt hamllit1g routine. it is enough to access the 110 module. di=t with load and transfer operations (AWL) or with the MOVE box (lAD. FIlD). You are recommended here to maintain a st rict separat ion benveen the main program and the interrupt handling routine with regard to the lIO signals . If you w:mt to process many input and output signals in the interrupt hand ling routine, the solution on the S7-400 CPUs is to use subprocess im" g~s. \\'hen assigning addresse" yo" assign each module to a subprocess image. With SFC 26 UPDAT]! and SFC 27 UPDAT_ PO, you updat e the subprocess images in the user program (sec also Chapter 20 .2 . I , "Process Image Updating"). On new S7_400 CPU" you can assign an input and an output subprocess image to each interrupt organizati on b lock (each interrupt priority clas,) and so cause the prn<;css imagcs 10 be updated automatically when the interrupt oceurs _ Sta rt in formacio n, tempor ary local data Every organization block deliv<.-'TS the start in fom lation in the fi rst 20 bytes of its tempomry local data . You can generate the declaration of the stan infomlation using own data yourself. or you can usc the temp lates from the Standard Library under Orga";"ario,, Blocks. In S7-300 sy,tems. the avai lable temporary local data have a fixed length of 256 bytes per priority class. In S7-400 systems. yow can specify the length per priority class by parameterizing the CPU acconling!y (parameter block "local data"), whereby the wtal may nol exceed a CPU_specifLc maximum. NOIe that !he m ini-

mum number of bytes for temporary local data t"r the priority class used must ~ 20 bytes so a, to be able 10 accommodate the staT1 information. Specify zero for unused priority dasses. Note that you can only dirc<.-1ly read Ihe .tart information of an organization block in lh~ block ilself. since temporary local data are involvcd_ If you alw require values from the start infonnation in blocks which arc located in lower call levels, call the system funclion SFC 6 RD_SINFO at the CO!Te'ponding point in the program (see Chapter 20_ 2_5. "Slart Information") .

AClual interrupt informat ion B)1es 4 to II of the staT1 information in the interrupt organization b lock contain the information specific to the triggered interrupt. In many ca<;cs, the components triggering the interrupt deliver additional information which you can then r~ad in the interrupt organization b lock using the system function b lock SFB 54 RALRJ>..l (see Chapter 2) .9.3, "Reading addi!ionallntcrrupt (nformation").

21.2 Ti me-of-D a y Inte rrupts


Time-of-day interrupts are used when you want 10 T1'" a program at a panicular time . e ither once only or periodically. for instance dai ly. In STEP 7. organization b ln<;ks OB 10 to OB 17 arc provided for servicing time-of-day interruptS; wh ich Oflhcse eight organization blocks are actually available depends on the CPU used. You can configure the time-of-day internJpts in the hardware eonfigurlllion data or control them at rtInlime via the program using system funclions. The prerequisite for proper handling of Ihe time-of-day interrupts is a correctly set real time dock on the CPU. Table 21 . I shows the start infonuation for thc time_of-day interrupt . The du.mmy val ue "" rcp""scnts the number of the associated interrupt organization block 10 to 17.

21 Inkrrupt lIandling

21.2.1 Handling Time-of-Day Cen ... r~1 remarks

Int~rrupt.

Performance characteristics during _.tartllp During a cold re,tart or warm ""'Iart, the op~"- ating system clears all sell ings mad~ wi tJ, SFCs, Selling' made via the hardware con figLlmtlOn data are relatHcd. Un a hot re start, the CPU resnmc~ servicing of the lim e-of-day interrupts in the fi rst complete ,can eye le of the ma tH program _ You can query th e status of Ihe time -of-day interrupt.'< in lhc st"rt -liP OB by ca lling SFC 3 I . and subsequ<:r>tly c a n ~c l Or re-Set and rca~ ti vate the interrupls. The time-of-day interrupts a"" service d only in RUN mode. Performance characteristic. on error
If a tim e-o t: day interrupl 013 is called but was not prognuIlmcd, the operating system calls UB

To start a time-of- day interrupt, you must fi rst set the star! ti m e , then activ~ te the interrupt, Y"u can perfoml the two a~tiviti c, separately via the h~rdw~rc configuration data or us in g SFCs , Note tbal w hen activated via th e hardware configuration data , the time -of-day intcrntpt is started automatically follow ing parameterizati on of the CPU , You can start a time-o t-day interrupt in lWO ",'ays:
t>

Single-shot' th e re levant OB only at the specified tim~, Or

j<

called o nce

<>

PeriodicalJy: depen d ing on Ihe parameter lISsignme nts, the re le vant OB i. started every minute. hourly. da ily. weekly, tnonthly or y early.

Following a single-shot limc-of-day int~rrup t OB call, the timc-o r-day interrupt is ~~ neckd You can HI,,, cancel a time -of~day interrupt wilh SFC 29 CAN_TINT. If you wnnt to un~e again use a canceled tim e of-day inlcrrupl, you must set Ihe s tart time again, then reaClivate the interrupt You can qLlery the statu, "f a timc -ot:day internlpl with SFC 31 QRY_ TlNT.

S5 (program e.~cclltion error). IfO B 85 was not programmed, the CPU goes to STOP. interru pt. that were dc sdcc led when the CPU was parameterized cannot be servic ed. even when (h ~ rekvan! is avai l_ able. The CPU goes to STOP.
Tim~-of-day

as

If you a~tivate a time-of-day interrupt on a ~in gk-shol basis, and if tbe start time has a lready passed (from the real-time do~k'" point of vicw), the operatin8 syslem calls OB 80 (liming

Thble 21.1 StarllnfQrmatio n lo,- Time-o f- Dav [nterrup" Byte

VariabLe Name
Olhx EV CLASS OExx STRT
~,

Il.!a Type IlYTE BYTE BYTE

Ileseription

Cnnt.nt, 11,,16#11 - UP
~\'~nt

b.nt elMS
Start ,oquest for the interruplOl3

'.'

B "'I6'!'II- OB.ll lJefault value 2 for all tim e -nf.day mtefTUl'''

, , , ,
6 .. 7

O BH PRIORiTY
OBx~

Priority cla"
all ,,-umber R e se,Ye <l Re,cned
lnt",",'~l with OBs called p<riooi(-a l1y

OB NUMBR

Olh,x J/FSERVllD

O B xx RESERVED

,
-',

BYTE

B# 16"""

BYTl' BYTE WORD I}lT

.
Se e dc><cription of S~C lH SET

O lh ~ _ PERIOD_ EXE

,m,

8.. 9
W

aBxx RLSERVl';O

I{esen:.-d
R C;<Tved

.
~

""
xx

"

OBu R ES ERVED

08",,_ DATE TTlvfF

'" DII1'Io_A.'I'D T IMF.

OccUITc'ncc of C'"Oo.t

Call c<l time ofOB

''''''"><'Dc, th e OB numbe" 10 to 17

I
error). IfOB to STOP,
~O

11.2 Time -of- Day Intcmlpls

is nOI available, the CPU goes

when more tban 12 interrupt cwnts with the same priority ","cur .imultaneously. The -'Acti\'c" option a ctivate, automati c Starting of the time-of-day interrupt. Thc "Execution" option screens a list whi~h allows you to choose wbether you want the OB to execute on a single-shol basis or at specific interval,. The final parameter is the sian time (date and time). \\'hen it save, the hardware configuration, STEP 7 writ es the compiled data to the System Data object in the offline user program Rlocks. From here, you can load the parameter assign ment data into the CPU while the CPU is at STOP; thcse data then go into force inunedi ate ly.

If you adivate a lime-o f_day interrupt on a periodic basis, and if the start time has already passed (from the real-time clock '. point of

view). Ihe time -of-Jay interrup1 OB is executed Ihe nexl time {hm time period comes due
If you set lhe real-time clock ahead by more (han approx. 20 s, whether for the purpose of corre<:tion or synchroni Ultion, thus skipping over the Slatl lime for the time-Qf-day interrupt, the operating system call. OB 80 (tim ing error), T he time_of_day interrupt OB i , then executed precise]yonce.
If yo ... set the real-time clock back by more than approx. 20 s. whether for the purpose ()f correc t; ot) or syn chronization, an activated time-ofday interrupt OB wi ll no longer be executed at the il1stam8 which are already past.

21.2.3 System Functio n, for Time-of-Day


IDt~r rupts

If a time_of_day imerrupt OB is still executing when the neXt (periodic) call occurs, the operat ing system invokes 09 80 (timing error) . When OB 80 and the time-or-day imerrupt 09 have executed, lhe timc-otC day interrupt 09 is restartcd Dlubling, delaying and enabling Time-of-day interrupt 09 calls can lYe disabled and enablcd with Sl'C 39 DlS_IRT and SFC 40 EN _IRT, and delayed and enablW with SFC 41 DlS_ AIRT and SFC 4 2 EN _AIRT.

The following 'ystem functions can be used for time-of-day interrupt control : "
"
;>

SFC 2g SET_T INT Set timeof-day interrupt


SFC 29 CA'-I_T1NT Cancel time-of-day interrupt

SFC 30 ACT_T INT Activ.te tirne-of day interrupt SFC 31 QRY_TrNT Query time-of_day interrupt

t>

The param eters for these systo m functions arc listed in Table 21.2. SFC 2g SET _T1!\'T Se t time_af_da)' inte~rnpr You determine the ,tart time for a time-of-day interrupt by calling system function SFC 28 SET_TINT SFC 28 selS only the 5tart time ; 10 start the time-of-day interrupt DB, you mu", ac{ivat~ the tIme-of-day int errupt with SFC 30 ACT_ Tl1\'T. Specify the ,tart time in the SDT p arameter in the formal DATE_AND_TThlE, for in'tancc DT#1997-06-30-08:30 The operating system igoores seconds an d milliseconds and sets thC8e values {O 7ero. Selling tho start time wil l overwrite the old start time value, if any. An active time -of-day interrupt is can_ celed_ that i~, it mu,t Ix: l"\:acti,"al~d

21,2 .2 Conligudng T1m~-of- Day Intprrupu with STEP 7 Th e time-of-day interrupts arc confi gured vi" the hardware configuration data. Opcn the s.cle~ted CPU with EDIT ~ OalECT PROPERTlES and choose the "Time_or_Day" tab from the d ialog box In S7 -300 controllers , the processing priority is permanently set to 2. In S7-400 controllen;, you can set a priority between 2 and 24, depend ing on the CPU, for each possible OB; priority 0 deselects an OR You should not assign a priority more than onc~ , a~ interrupts might be lost

21 Interrupt Hamll i,,!!


Table 21.2 SFC Paramete rs for Time_of_Day interropts

"ME

\\"#16#0401 \",#16>11001 \>,"#16111201 "'.-"#16#1401

SFC 30 ACT_TiNT Activate t1me-of-day interrupt A time-of-day interrupt is activated by calling system fnnction SfC 30 ACT_TINT. When a TOD interrupt is activated. it is assumed that a time has been set ror 'he interrupt. If. in the case of a single-shot interrupt, the SIan time is already past, SFC 30 repons an error. In the ca.~e of a periodic stan, the operating system calls the relevant OB at the ncxt applicable time. Once a single-shot time-of-day interrupt has been s<.-'fViced. it is, for all praeti~al purposes, canceled. You can re-set and reactivate;t (for a different start time) if desired SFC 29 CAN_TINT Cancel time-of-day Interrup t You can delete a stan time, thus deactivating the time_of_day interrupt, with system function SFC 29 CAN_TINT. The respective 08 is no longer called. If yo" want to use this sarne time of-day interrupt again. you must fIrst set the start lime, then activate the interrupt.

SFC 31 QRY_TlNT Query tlme-of-day Interrupt You Can query the status ofa time_of_day interrupl by calling system function SFC 31 QRY_ TfNT. The required information is r~turned in the STAruS parameter. When the bits have signal state 'T', they have the following meanings'

o
2
3

TOO interruP I disabled by operating system TOD interrupt not acti vated and not expired ( - Reserved-) TOO interrupt 08 loaded No disable (and following: - Reserved_)

1 New TOD interrupt rej(X;ted

4 5

21.3 Time-Delay interrupts


A time-delay interrupt allows you to implement a de lay ,;mer indep,,,,dcm ly of the standard timers. In STEP 7, organization blocks OB 20 to 08 23 are sct aside for time-delay interruplS;

!1.3 n"",. Ocl aylnremrpt>c

Tlohle 21.3 sun Inr""""tiOll roo TUM-D. lay IDle""",'

IIY'O0

v.ti~\)~

'1.mo

0.1.a TJipe
BYTC BYTE

De<criplion

Con""n"
fl#l ~~ 11 _ lIT' evonl

"

...

OB"" FV CLASS OB"-'._STRT_INF OBu_PRlORITY


o ,~

, , ,
~,.7

Event. 01 5t"" requ.e.t for lho inlc"fTllpt OB


I'riorily clhS

B#I6<:21 _ 00 20
Ikfioult "~l","" J ~o 6

n YTF

o.~

OR KUMBR RS" IIV F.[)_

ODu RESIlRVtO
U"~ .

, ",.. ,
"flME

BYTE

011 """,lin
Rc>e1""\"ed R..... .".,...J

(OB !O '" OU 23) R"16or<x


.

'Ynl
WUW

.
Se, ~ .",ripti"" "f SFC 32 SRT DINT s deSCription ~f SFC J2 SRT_OlNT

51G:<I

lob idcnl,/iC"tion
expired d.\~y time
Oc(:lU1ef\Ce of .,,<."n!.

8.. r I
12.. 19

Olhx_DTI),1E
ORu_DA1F._Tf\.fF.

DATE_ A)\."l)_ T1:>'"!E

Call lim. of OR

tile 011 n"""""" :!O 10 23

which

"r

"~tua\ly

the,e four organiuti<m blocks are avai lable dcrend. on the C PU used.

The priont;c, fOlr time_delay i" t~tTupl OBs are programmed in thc hardwMe configuration
d~ta.

tim~.<Jclay interrupts. On a hoI n::'lISn. the sc(t;nl,ls are remine<! umil pnK:c.lsed ;n }tUN mode. whereby !he 'residual cyc le'" ;s cOlUl led as part o f lhe ,(art-up rout;nc.

Table 21.3 M10Wli the ~UI" in fonna.t;on for the dnu.. delay inlcnuplS. The dummy value x." .. repn::~m. tbc number of Ihe associoted intcr_ Npl orgaru/.at;on block 20 10 23.

21. 3.1 HAndling Timc- OcJMY Inlcrrupls


GcnerMI
r~marb

You can <tart a timc-<lelay inlerrupt in the Slan up ........tine by calling SFC 32. When thc delay inl""alllas expired,!he CPl; mUSt be in R\.N mode in oro", 10 be able 10 Cx~te tb<' rdevam olllani2arion block. If lhis i~ nol the CllSe, the CPU w~it!\ \() call !he organization bl"",k until the slnn- "p routine has terminated. then calls !he limedelay interrupt 08 b<:fo...., the first nctwork i" Ihe main program.

A limc-delay interrupt;~ '!lIfIed by calling SfC 32 SRT_DlNT; thi. system fUllC.ioDalso pas.cs the delay inte .....-al and the number of IlIc &ele<:!<>cl organization bluck w the ope .... ting sYStem. When the dela y interval has expired. (h~ Oli;$ called. You Can canc,! servicing of It time-<lelay in!.<;TruP!, in which case the a~jlX:ia!Cd OR will t\O lon ger be called. You can qne'Y!he Slatus of a !i mt-deLay interruP( wi th SFC 34 QRY_Olt-,..
rHf"nn . nc~

.. \' Hr(lrma n cr chan<.. erilltJrI on t r .... r


If no tim..-dclay in1ctnlfll OB hils been proI:Il"mmcd.. tJo. opcralinl,l ~y"lcm call5 OB 85 (pT(>gram exec ulion ~"fY()T). Iflhere is n o OB 85 in Ihe user program, lhe CPU goes 10 STOP. If the dday imerva l has cxpi<ed and !he a,"oci a!~'<J o n i ! .Iill cxccutinj;, Ihe oremling .ystem cal 11 on IIU (timing erro<) or goes to STOP if !h~"", is no OB 80 in !he user program.
T ime-delay interrupt. whieb "'en:: deseleciCd during CPU paramet~riza.ti()n cannOt be ser"i~l!d. c,'en when the respeclive on has bttn prOl:lf&mm<:d. The CPU goc~ to STOP.

characlernllu during ..anup

On a cold restan or warm ~.UI". the open"ing sy~tem dclclC" all progt;lmmcd S\:n;ngs for

361

21 Intern,ptJ-l"ndling

Dis a bling,

dehl~ing

and enabling

21.3.3

Sy~tcrn FUll~tlons

ror Time_Delay

Interrupt. Tb e time-deJay interrupt 08, can be disabl~d and enabled w ith system functions Sl'C 39 nls IRT and SFC 40 EN lRT, and delay~d and Clw bied with S.I'C 41 DTS_ AIRT and SI'C 42 EN AIRT. A time-delay interrupt call be controlled with th~ following system funet.ions:
0>

SFC 32 SRT DL"IT Start tim e-delay inter11ll't

21.3.2 Configuring Time- Delay with STEP 7

Int.~rrupts

"
0>

SFC 33 CA" DINT Cancel time-de lay intern,pt SFC 34 QRY_DINT Query time-dclay int.enllpt

Time-delay interrupts are config llred in thc lwrdware configllTation data_ S imply open the selected CPU with Eun --;. OBJEC"J PROPERTIES and ~hoose the "Interrupts" lab from the dialog box. In 57-300 controllers, the priority i, I'ennanently preset to 3. III S7-400 controllers, you can choose a priority belween 2 and 24, depending on the CPU, for e ach possible 08: choose priority 0 to deselect an OB. You should not 8s>ign a priority more than once, as interrupts could be losl if more than 12 interrupt evet){< wi th the same priority OCcur ,im"llaneu"sly. When it <lives the hardware configuration, STEP 7 writcs the compiled datll to the Sy.<lem Data Object in the oillinc user program Rlods From h~rc, you clIn trallsfer the parameter assignment dat" w h ile the CPU is lI! STOP: the data take effect immediately.

The pa rameter, lor these sy.tem t\lt1ctions are listed in Tahle 21.4. SFC 32 SRT DINT Stan Time-dduy interrupt A time-delay interrupt i. Rt8rted by calling system function SFC.n SRT~DTNT The SFCcall is also the .tart time for the programmed delay ;lI1crval \Vhen the delay interval ha.> expired, th~ CPU calls !.he p rogrammed OB and passes the time delay value and a job identificr in lh ~ start information fot tllis OR 'fhe job iden tifier is ;;pccified in the SIGN parametcr for SFC 32: you can read the same "al ue in bytes 6 and 7 of lh~ start infonnalion for thc assuciated timedelay inlerrupl OB. Th~ time Jelay is ~et ill increment;; u f 1 ms. Th~ accuracy of the time de b y is also 1 IDS . .'-IOlc that execution of the time-delay interrupt OB may its e1fbe dclayed

T.ble 21.4 S'FC PaTIlmekrs for Time Delay Internlpts

I ,i

,
I "ON

'

ti

Error

infom1at~

31>2

21.3 TIme-Dclay JnlC1'TUpb<

T.blf 21.3 S/art Inf""""';",, (If 'fime-Dday Interrupl$

Job j

SI-C 32

which of these four OTgl1l1lution blocks are IOlUany available dep"nd~ on the CPU used. The priorities for lime<lday interrupt OBs are

programmed in the hardware configuration


data.

time-delay interrupts. On a hot restan, the settings are retained until proce~~ed in RUN mode. wherehy th~ residual cyc le" is counted as pan oflhe stan_up routine . You can <tan a timc-delay interrupl in Ihe ~lat1_ up routine by calling SfC )2. When the <klay imetval ha~ eJtpired, the CPU mu5t be in RL"N mode in order to be able 10 eJtecute tile relevant organization block. If !his is nOI the ca"". the CPU waits to call the organization block until the start-up routine h", tcnninated, then calls tlw timedelay interrupt 013 before the firllt network in the main program Performanct charaNens tics (In .rror
If no tlme-delay interrupt OB hu be= programmed. the operating s)'>'tem calls 0 8 85 (progrum execution error). IftheI"C is no 08 85 in th~ u= program, thc CPU 1I0000s to STOP. If the delay interval has expired lind the I!s'!OCialed 013 is still eXe\:uting.!he uperating system calls 08 80 (timing error) ur goes to STOP if there is no 013 80 io !he llser program.

Tahle 21.3 shows the sum infonnation for the

t;me-d.la), intenuplll. The dummy ,-aloe l<X rep~nlS the number of Ihc associated imer-

rop' orpnizalion block 20 to 23.


21.3.1 Handli ng
Tim~.Oel~y

Interrupts

Gen enl .... marks A time-&Iay ;n,errupt is 51aned by calling SFC 32 SRT_ DTlI<"T: this system function also pas..e. the delay intclVlIl and til<; number of the
SclCC:led organization b lock 10 the operating
~)'$Icm. When (he delay imelVa! has expired, ll1e 0 13 is called

You cun cancel servicing of R time_delay imer_ rupt, in wh ich case the associaled O U will no

longer be called. You can query the


rupt

statu~

of a time-delay inter-

with SFC 34 QRY OT'\'T.

Perronna nce characteristics duting sianu p

On a cold lestan 01 warn, !"eStan, the o~rating system deletcs all proiPl'mmed ~ctting< for

TImc-dday interrupts which w<:Te deselected dllnng CPU parameteriuuon eanlWt bC' serviced, even when the respect.ve on has be= proanmmcd. The CPU g~s 10 STOP.

'"

21 lnlerrnpillandling

21.4.1 Hand ling Walehdolli nlerru pts


Trlg"lI"rlnl:; walchd"lt Inlcrru pl~ In lin S7-300 In an 87300. there i. n limiled choice of watchdOli interrupts with fixed priority. depending on the CPU. You can ..,1 Ihe imerval in the range from I millisecond \0 I minule. in ' _millisec_ ond inerem=ts. by parameterizing Ihe CPU accordingly (;m interval of SOO IlS on the CPU 319 from finnwa~ version V2.6). Trlglj,erlng watchdog Inttrrupts In an S7-41)0 You define a watchdoa interrupt when you paramelerize the CPU. A watchdog interrupt htlS thr~ paramelers: the mterval. the phase offset, and the priority. You Can set all Ih~. Spc<:ifiablc values for imerval and phase offset an;: from I millisecond 10 I minute. in I -milli. second increments: the priority may Ix- seilO a value Ixtw.,cn 2 and 24 or 10 :cero, de?"nding on Ih., CPU (zero mean s the walchdog ;nt.,rrupl is not active).

.
OR

" " " " " " " "

,, ,,

Time

Int~rvat

I'1!tic

Sooms ZOOm.

..

"m,
o m~

"",,m,
20

." ,, m,
,~ ,~

'm.

, ,
B

Priority

, m,

'"

tOms

Om.

" " "

UP 10 RUN. The call in!t8nl for a watchdog intCTT\Jpt OB is Ihus the lime interval plu5 the phase ofJSO:I. Figun;: 21.1 .hows an exampl., of Ihls. In the left SO'Ction. no phase offset is !let. and consequently stan of processing ofthc low' er priority organization bloc\.; is delayed by thc cum=nt processing time of the higher priority or gan;7.8tion block in cach casco

STEP 7 provides the organi:rotion blocks listed in Table 21.n, in their maximum confIgurations.
PII.~e

nffse l

The phase 01Ise! can be used to process walch dog interrupt programs in Ihe precise lime frame even ifth.,y have the same time inteJ'\"lI1 or a shared multipl.,. U$e of Ihe pbas., offs.,1 nchieves II highcr int.,rv8] accuracy. The stan time oflhc lime interval and the phase offSet is the instant oftraosition from START

If. on the other hanu. a phase shift is configured and il i$ greater than the maximwn processing lime of thc higher-prionly oraDnizatKID block. Ihc lower_priority organization block is processed in the p~isc lime frame.
Performancr characl('rlsticl during Slartup Watchdog intemJpts cannot be serviced in the Start.up OB The time intervals do not begin l.tnlil a transitinn is made to RUN mod.,.

""
PI(X",.sing of higher_

Without ph.... off,at

"' "

With ph... o"'.t

priority OB

PhBseoff"1

n.., ..., "fiM Iow<-t_priority OB .. dt.iftod by


the
"I~u~

W; th .... ffici ... tIy hiah


pri"";ty

olf.. ~ the I"",.,..

pro<.c";'" ,ome of'he higher_priority 09

OD >tartS exactly .11hc rime i""'ral

21.1 Example of Ph... Offs.et for Walchdoa TmemJpll

'"


21.5 HanlwareJnlemlpU

Puformanu ch a no:ttrlsllcs On er ror


When ~ same W3tcho:log lnl<:mlp' ;s generated AJlllin willIe the associated wa tchdog inleTTUpi

From hcff. you can load the parameter assignment data into the CPU while the C PU is al STOP: tbe data take effe<:t immediately.

handl;"1!: 08 ;5 still

c~ecllting.

Ibe opaafing

system calls OB 80 (timing error) _IfOB 80 1I.as not been prognlmmcd, Ihe C PU g",," to STOP.

21 .5 Hard war e Inler r upts


Hnrdwa~ interrupts are used 10 enable the immediate dCte<:lion in Ihe lI"r proaram of e\"t'11IS in tbe controlled process. making it possible 10 ,"".pond with an appropriale inlerrupt h.andlinJ. routine. STEP 7 provides organiution blocks OB 40 10 09 47 for """'kina hardw.", inttmlplS: which of these ciabt organizalion blocks "'" aetually .,-ailable, hOWeVCT, depends on the CPU. Hardware intarupl bandlmg is progl""mmed in the hardware configuralion data. With system nlOctiom SFC 55 WR_PAR,VI. SFC 56 WR_ DPARM and SFC 57 PARM MOD, you can (~)paramcteri~c the modules with hardwn~ interrupt capability even in RUN mode.

The operating system saves the watchdog inle" "'Pi that was no! ~rviced .(!Vicina il at the

nex t opportunity. On ly one unscrviccd walchdog imcrTIlpt is saved per priority class. ",garo1C$8 of how many unserviccd watchdog inter. rupts accumulate.

Watchdog lnlcnuplS Iblll wom: lk"lccted when the CPU was parameterized cannot be serviced, even when the =5pOfIding OB is .".il.ble. The CPU joes 10 STOP in \his casco DlsabU nv-. delaying a nd en a bling
C a lhna Qf the walchoog interrupt OBs can be

disabled and enabled with system funcllOns

SFC 39 OIS_IRT and H e 40 EN_IRT and


delilyed and enabled w ith SFC 41 DI S_A IRT

and SfC 42 EN_AIRT.


2 1.4.2 ConflKurlng Watch dog InterruptI " 'llb ST EP 7

Table 21.7 shows the start information for the process intcrrupt . The dummy value:tX represcnt~ the number of !be associaled interrupt organizatlOll bloct 40 10 47.
1 1.! . 1 Ge nerarin i: . Hardwart Inlen-u pl
A hardware intarupt i. IIcnenucd on the modules ..itb this capability. This could, for ~am pic. be a d.igital input module thaI detects I signal from the process or a fUnction module that generates a hardware interrupt because of an activity taking place on Ihe module.

Watchdoa inteJnlpts an:: oonfigurW via tlte hardware confiiUJ"lllion data. Simply open the
oel~ted TIi;S and

CPU wilb EDIT

--t

OBJECl" PROPER-

choose the "Cyclic Interrupl" tab from Ihe dialoll box.

In S7-3OO controllers, the processing priority is


pcrm8nently sct to 12. In 57-400 controllers, you mny sc t " priority between 2 and 24 for each p<lnibl~ DB (CPU-spcc ific)~ priorilY 0 de"If.l(:ls the OB to wbi ch il is assigned. You should nol auilln a priority more Ihm once. as interrupts miahl be I"", if more than 12 internIp{ cwnts wilh tbe same priority oc""'" simulwu:ously.
The interval for each 09 is sc1e<:ted under

By deflult. hardware interrupl$ a~ dtsubled. A parameler is uscd to cnable servic ing ofa hardware interrupt (Slati c parameter). and you can specifY whelher the hardw= inlerrupt should be generated for a coming e~ent. a leaving ".t'11I. or bolh (dynamic parameter). Dynnmic paramclCT"S are paramelen ..... hich you can modify.1 runtime using SFCs. In an intelligent DP .In.., equipped for this purpose. you ean initiate a process intelTUpl In 1M maSICT CPU wilb SFC 7 DP]RAL.
The hardwB,"" interrupt i. acknowledged on the

Exeo;ulion'. the delayed call instant under "Phase Offsct~. When n \e$ Ihe hardware configuration. STEP 7 wrileltlte compiled data to the S)"~le", Dala object in the omine user program Blocks.

moduk when the o<ganizalion bloct containing the service routine for thaI interrupt has finished execuling.

21 Julerrupt Handling
T.b l~

217 . Stan lnlonrullion for Han1warr Interrupts

, , , , ,

B,)'I"_ . '''-'''ri;>hle 'NKmc 0 OB~ ev CLASS OBxx - STRT- INF OB,,", PIUORITY

Data Type BYTE


I3YTE

n.::.ciipt;<>tt
Event cia" Stan request for Ihe interrupt OB Priority C~"\5' DB numb-cr ReseT"ed I/O id~nti fi<'a tion

Conte"t< B1I1 (,# I I ~ UP event 1311161141 - 0B41 Defauh .alu~> I n to 23 (013 40 lO 47) B'I161txx

IlYTe

OB NUMIW OBxx RESERVED OHxx >0 FLAG


OB~

IWTE BYTE
B~E

.
B".I(,#54 _ inpu'moouk. input s" bmo<l<,le BII 161>55 - output module. out put submooule

6 .. 7

OHxx_ MDL ADDR

WOHD

Module

'''~rting.

add",,, of compo_
o~nl; In);!':c"";n);

8 , II

OB",,_POIN"I

~OR

DWORD DATE
AND T IME

12 .. 19

OBxx DATE TWE

intC1"nlp' Intc"ITupl informalion OccuITcm'c of


O\ ' ~ n l

Call tim e ofOll

xx "'pre sents the OB nurnl>er< 40 t" 4 7

Rc~nlution

nn

th~

S7 -300

If an cvcnl ",",CillO during "x"cution uf u hardware inlCtT>lpt on which ilsel f would trigger gencralion oflhe same hardware interrupt. that hm-dwarc inte rrupt will b~ lost when the eV"m Ihat lriggered it is nU lung<.--,- prc""nt following acknowledgment. It make. no diffcn,nce whcther th" event comes from thc module whose hardware interrupt is currently being serviced or from another moduk. A diagno'lic interrupt can b e generat"d while a hardware interrupt is being 5ervieed. Ifanoth.". hard ware interrupt oCcurs On the ,arne channel between Ihe time thc lin;t hardware interrupt was g~-neroled and th" ti me Ihm interrupl was ;lcknowledged, the loss of the laner interrupt is reported via a diagnostic inlerrupt to system diagnostiC-'.
R~sol"tion

event occurs o n another chamle l on the same module or on another modulo:. the up<:tating system restart:; thc 08 as soon as il has fin ished cxecul1ng.

21. S.2 Servicing Hard""IT Inte rrupt. Qun)'ing int errup t inf"rmatiou
1b~ stan address of th" mod"k that triggered the hardware interrupt is in bytes 6 and 7 ofthe hardware interrupt 08 's start information , If thi , address is an inpld ;lddress, byte 5 of thc ,ran infonnatio n cont ain, 13 # 16#54; Olherw i'" it contains 8 # 16#55. Ifth" module in qu"slion is a d ' gilal inplll module. hyl"s ~ to 1 t contain [h e Status o f Ihe inputs; for any other typ-e o f module> Ihes.c bytes cunta in the interrupt status of the module.

on th e S7_400
Interrupt handllng lo th" start-u p routine

If during execution o[ a hardwarc interrupt OH an e"~-nl occ"r< on Ihe same channel on the sam e module which would trigger Ih" .ame hardware interru p l. that inlem,pl is 10<1. If the

In the stan.up routine, the modules do not generate hardw are intcrrupl.>;. lnterrupt hanilling begins wilh th e transition to RU N mod~. Any

21.6 DPVllnterrupt. go into force im mediately following loading; the parameter as> ignment data for the modules take effect after tbe next start-up.

interrupt. pend ing at the time of the tran sition are 1 0,t. Error handUng If a hard ware intcITUpt is generated for which there is no hardware interrupt OB in the " ,e r program, the operating system calls OB 85 (program e ~ecution error) . The hardware interrupt is acknowledged. If OB 85 has not been programmed, the CPU goes to STOP. Hardware interrupts deselected when the CPU was parameterized cannot be serviced, even when the Olh for these inK"mJpts have been programmed. The CPU g008 to STOP. Disabllng, delaying and
~nwbllng

hardwar~

21.6 DPVl Interrupts


PROFlBC"S DPVI slaves can trigger the following interrupts in addition to Ihe Iypes previollsly known with SIMATIC S7:
l>

Status interrupt. e.g. if the DPVI slave enanges its opernting mode: the interrupt organization block OB 55 is called, Update intetT\lpt. e.g. if the DPVl slave has been paramNerized over the PROFIBUS or dire<:tly; the intetT\lpt organi7.at ion block OB 56 is called. Ven dor interrupt if an e vent eDvisaged by tbe vendor occur. in the DPVI slave: th e interrupt organization block 0 8 57 is calJed. Tbe ev~nts which can trigger the interrupt are dofined by the vendor of the DPV] , lave.

I>

Calling of the hardware interrupt OBs can be disabled and enabled with system funCions SFC 39 DIS_IRT and SFC 40 EN_IRT. and delayed an d enabled with SFC 4 1 DIS_AIRT and SFC 42 EN AlRT.

\>

21.5.3 Co ntigurlng Hardware Inlerrupts witb STEP'


Hardware interrupts are programmed in the hardware ~onfiguration data . O!>"n the selected CPU with EDn ..... OBJECT PROPERTtES and choose the lnt<.-'ITUpts tab in th e di alog box. In 57-300 systems, the d efault prio rity for OB 40 is fixed. In 57-400 sy-;tems, you can choose 3 priority between 2 and 14 fnr ~very possible OB (on a CPU-spe<:i fic basi.); priority 0 de,elects execution of an OB. You should never assign the same priority twi~e beea,,~e inte1"rupts can be lost when more than 12 intemlpt events with the Same priority occur simultaneous ly. You must also enable the tri ggering of hardware intemlpts on the respective modules. To this pUrp<Jse, these modules are parame\erized much the same as the CPU. When it savu~ the hardware configuration, STEP 7 write, the compiled data to th~ System Data objoct in offi ine user program Blocks. from here, you can load the parameterization data into the CPU whi le the CPU is ;n STOP mode. The parameterization data for the CPU

The origin of the interrupt. the interrupt specifi~ and the length o f interrupt infOlmation additionally avai lable ~ spe<:ifi(>ci in the start infonnation of the DPV 1 interrupt organization blocks (Table 21. 8) . You can read the supplementary interrup' information using SFB S4 RALRM (5"",, Chapter 21.9.3, "Reading additional Interrupt lnformatiOll''). Performance cbar.Clerl.dcs dllrlng startup PROF IBUS DPV ] slaves can also generate interrupls whcn the master CPC" is at STOP. In this state. the master CPU ~annot call an internlpl organization block: process ing of the mis;;ed interrupts is nOt carried out when the CPU en ters the RUN state However. the rcce iyed intemJpt ~vents are ent~re<l into the diagnostics buffer and th~ module statuS data. You can read the module status data using the system function SFC 51 RDSYS5 T. Error handling Ifthc corresponding DPV I interrupt OB is missing in the u~er program wben the DPVI interrupt

'"

21 Interrupt l landling

is tri~ TUd, the Opt"r3ting sysu:m calls the 0 1l 8S ... (prognun "",<:cutlan fault). T1Ie DPVl intenupt

is Kknowledgllflhe DB IIj is I'lOl: pres"'t, tbt: CI'U CDter.i the S T O P ~t.alc.

T .bl t
6~1.

2 1 .~

Stan In formation

rO<' VPV 1 Inlerrupt.


Data Type BYTF BYU:
ik>eripliun
E,,~nt

Vat,.ble Name OBxx_ EV_CLA SS OD.u STRT_ INF OBu]R10RlTY Olh ... OU _ :-:UMBR
0 1l1Ol_ KESERVED

I Contents
6#1611 1I -

, , ,
0

clan

lt1' .vCnl

Sian "'que", f"nhe

R1I16"xx B"I6#02 - defaul. "aluc


B"I6'<x:<

O'u

,m

Priority cla~! OB number


Rc"",,'cd

,
6.,7

[lYTE BYU:

WlI 6!lS4 - input moduk. input submodulc B"I6/,~S - oulpUt module:. oulpUt ~ub<nodulc

OB"",_IOJ'LAG

"""
WORD

L'O itktlufic.UOD

OBu_MOL_ADOR

!>1OOulc Itan;", addre ssofoompo!!e<l! tt1iiefU'i Ihe Wlerrupl !. onJilh of intorrupt <Iota rccord [(Ientille.uon of ioterrupt .ype
B'jJ6<irOO B"I~I B"16!iOl B:: 16I:()) B"I6!t04 ~ 8 "'16"03 B::l6:06 ~ a rt l6!:Oi .. IF B ~ I &:<20 .. 7E B~IMt7F ",.crv.'<I diai<>'lic IntCTTUP' han:lwatc LIl'em.tp' removal Interrupt itucrtion In,omup1 ...IUI interrupt up<btc interrupt n:scn..:d "cndor InlCTTUPI

OBu_LEN OBu _TY PE

OYT E BYTE

"'""1'>'<'<1

"
"

OBu_SLOT

BYTE

SIo. number of ~O",p<Jnen l triuer. ;"II.he interrupt Sp<.cilkT Bi", I and 0: 00 re~n.d 0 UP .."em 0 DOWN e"enl wi,h error DOW"< evenl w,th funilcr e<mrs Bit 2: o no addi'ional tdcn ..... kdgment required additiooal acknu",l<:dgmcnt required BilS 3 to 1: rescn-cd

OBx,,_ SPJ:C

BYTlO

,, ,,

12 ..

Olh~_O ATIi_TL\tlo

xx ~n\l

"

DATE AND_TIME
~6otr

Occurrence of event

Call tunc uf OB

tho OB number> 55,

'"

21.7 M ~hiproccssor Interrupt

O;.ablin.::, delaying anti enabling Ca lling the DPY I interrupt ons can be ,\isable<! and enable<J using SFC 39 DIS_TRT and STT 40 EN_lin respectively, and delayed and cnabTc<I nsing SfC 41 mS_AIRT and SFC 42 ENj .. IRT res pectively. Conllgurlng OI'VI intcrrupb "ith STEP 7 T he DPVI interrupts are configur<:d using the Hardware Configuration tool. Open the selected CPU using EDIT --; OBJliCT P!!.Ul'U{ TIES, and sel""t the "Imermpl'" tab in the properties window which is then displayc<l. ThedcfauJt priority i. 2. You can sct thcpriority betwcun 2 and 24. Pri ority 0 deselect, the interrupt. DPV! interrupts which have been de .,. Jcctcd catinO! be executed, even if the eorre8p<Jnding OB is present. The CPU then enters th e STOP stmus. You nH>l't additionally parameterize interrupt Ifi ggering on the corre'ponding DPY I sls,-e . When ",ving the hardware con r-gun.tion, STEP 7 writes the compilc<l (lata into the Sysfern dam object in the oHline user progratn Blocks ; from here. yon can download the paramc!cri7--'ltion data 10 the CPU when in lhc STOP staIDs. The parameterization data for th e

CPU are immedi atel y efleetive fol1owing down loading, tho,e for the DPYI slaves following the next SlJrtul'.

21.7

l\1ultipro\!~ssor

Interrupt

The multiprocessor interrupt allows a synchro_ nous response to an event in an CPUs in m ult i-

proceso;or mode. A multiprocessor in~crrupt is triggerNi using SFC 35 MP_ALM. Organi zation block OR 60 , which has a flxed priority of 25, is the OS u,ed to service a m ultiprocessor interrupt. Table 21. 9 shows the assignments or the ,tan infonn atiofl for lhe muiti-pr(X;cssor interru pt.

General remark.
An SFC 35 Io.-1P ALM call initiatcs execution of the mult iprocessor interrupt OR Tfthe CP U is in single- processo, mode, Oil 60 is "lart~,j immediate ly. In multil'rocessor mode, OR 60 is started simultafleously on aU participating CPUs, that is 10 say. even the CI'U in which SFC 35 was called waits before callin g OB tiO until aU the other CPUs have indicated thaI they are ready.

Start Information for

Ih~

Multi-pmce.",r Interrupt

mterrup ~

interrupt

'"

21 In terrupt Hand ling Table 21 .1 0 Parameters for SFC 35 .\1P ALM

TIle mult ip rocessor interrupt IS not pro g ram med in the hardware configuration Jata: i1 is already prese n t in every CPU with mull ieom. pllting ,apability. Desp Ite th is fad, however. a sufficien t numher of local data bytes (at least 20) m llst still be reserved in the CPU's "Local Dam" ta b unJcr priority cla ss 25 . I'erformancc ch,,,acterlst.lcs d u r ing st" rtllP The m ultiproec<sor interrupt is triggered only in RUN mode. An S FC 35 call in the ,tart-up routine terminates a fter remmins error 32 9 29 (W # 16#!!OAI) as funelion value. Perform an ce ehurllcteristlcs on {'rro r If 013 60 is Sli ll in progress wIlen SlOC .>5 is recallcJ, th c system function remrn, error code 32 92 8 ('';'lIt16#~OAO) a s function value . 00 60 is not slaTted in any of the CPUs T h u unavailability o f 0 1> 60 in one of the CP Us at the time it is called or the d isabling or delayiog o f its ex~c lltion by ,ystem functions has no ctlc ct, nor does SFC 35 repon an error. Di.llbling, delaying and enablin g The mu lliprocessor OB can be disabled and cnab leJ wiLh system functions SFC 39 0 15 _ TRT and SFC 40 EN_TRT respectively. and Jclayed and ena bleJ wlIb SFC 41 DIS_AIRT anJ SFC 42 EN _AIRT r~sp~etiyel y.
S f C 35 MP _ALM ,Vlultipl"flce..or Interrupt

21.8 Synchrono us Cycle In terrupts


Re rc rencc is maJe to isoehrone mooe ir a prog"nn is executcd in "yn~hronism with the PROFIBUS DP eyck In co njuuction wit11 co nstant bus cycle times, othi s results in reproJ ue ib1e ,." sp"ns ~ times of equal length to the 110 . The user program cxccuteJ in isochronc mode i, pre'~nt in the organ i ~ation bloch OR 61 to OR 64. The system fi.lIlcliom SFC 116 SYNC_ PT aod SFC 127 SYl\' C 1'0 arc available for updating of the p rocess ima gc in isoch ro ne mode.
You confogure isochronc modc using the Hard-

tool (s~.., s e~lion. "Configuring ~on't~nt bu, cycle times anJ isochrone modc" in Chapt.,,- 20.4.3. S ~cial Functions for I'ROflli US DI'"). Table 21.1 I shows you the Win informalion for the synch ronou, cycle interrupt,. The dummy value xx represent' the numb~r of the ~ssociateJ interrupt organizatiou block
wa~e Configu~ation

61 to 64 .

21.8 .1 Processing Ih e Sy n chronous Cyele Tnte rrul)tS Thc synchronous cycle interrupt is triggered by thc Global Control ~ommalld of the 01' master.
S~ehronous ~ycl~ interrupts are only procc,s"J m th" up"",t ing mooe RUN. An syn. chronou, cyde inten upt in the STARTUP, STOI' or HA LT states is rejec ted. The number ofUB calls which have not yet been executed is present in the stan informalion of the isochro ne mode 00 whcn called for the fIrst time in R UN mode.

A mult;proce"or interrupt is tri ggered w ith system funel ion S FC 3 5 MP _ALM . Its parameters ar~ li sted in Table 2 1. I O. The JOR parameter allow, you 10 forward ajob idenliti~r. The sa me value can be read in bytes 6 and 7 of 00 60's start infom lation in all CP Us .

Error han d ling


Han synchronous cycle interrupt arrives befo re the associated synchronous cycle inl~"IT\.1p! 0 0 has been eompletcJ, a timing error i. signaled. This can oc~ut i f the user program dwells 100 long in an ,ynchronous cyc le interrupt O B or if

To bIt l1.1 1 !>I.... Informa';"" fOJ Synchmtl""" Cycle In,tmlpII

0''''

1\ ;

execution bas been imc""pled for 100 long as a resull of program compOncnLs of higher prior_ 1ty. Tbe Of) called by Ihe "\00 carly" interrupt is n:je<:ted. and ,he OB RO "Timing elTor" is called. A reaction can then be made here 10 the timing error. The number offailed synchronous cycle interrupts is output in the next processed synchronou~ cycle intcrrupt OB ;n Ihe stan info. In the eyeDI ofan error. the DP mastercanomil the Global Control cOJ1UlUnd (Ge) or send il offset. This '"(}C violatioo is displayro in tbe sIan information oflbe neXI 5yncivonous cycle h\1crrupt DB which is called correclly.
R

21 .8.1 h ochronc UpdatlDIil O f P roceu Ima gt

The Hardware Configurnuon tool Can be u<cd 10 IIssiiJl partial process iltlllges to an synchronous cycle iuterrupt DB . ThC!.il images an: not updated automatically The system functions SF C 126 SYNC PI and SFC 127 SYNC]O m u st be used 10 updale the inp uts and "utputs respectively. Updating is canied 0111 in i5OChlOne mod., and with data co",i~len~y. The ....0 SFCs mwn "Diy be called ,n an syncllronous cycle interrupt DB. Direct acceu 10 tbl'SC partia l process IIlliIges should be avoided. Ta ble 21.J2 shows the parmr>eler$ of the SFC 126 SYNC]l and SFC 127 SY)1C]O.
Th e pmial process im.ges are nm IIpdMC<! if an errQr is dCIe<;lcd . Excepliooi:
I>

D isablin g, delayin lil Mod en , bll nK Call ing oftbc syDChronouse~le interrupt DB. can be: disabled and enabled "'ith the 'Y<tem funelions SFC 39 DiS_ IRT and SFC 40 EN_ IRT respectively, and deuyed and enabled with SFC 41 D1S_AIRT and SFC 42 EN_AJRT <"Cspectively.

Ifan ac~ess oce,," when updati ng pani,1 process image of the inputs. inputs of faulty modnlQ ' " 5\to ''0-; OB 8S "'Program execulion error" is ealled.

"ITQ,

the tbc tbc not

I>

A ~OI'IsisU:ncy warning is generated if it was

not poMible 10 trnmmi! lIN:: complete data

21 Interrupt Handling
Table 21 12 With SFC of the SFC. for lsochrone Updating Of Pmce" Image Oedaration INPUT RFTUR..""" OUTPUT
Data Type

~arame t e",

Parameter
N;'lJOe
,~,

Contents. Ue'CripliOll
Number of partial pmcc", image 1j"'16#()1 to B"16'l1E Error information

'"
126

m m m

BYTE
,,~

RFT VAC
t 'LADDR

'"
~

WORD

Ln Ihe event or on aecn, error. the add", .. of the fIrsl byte caminl! the ~rror

coru;i"l<:nlly to the outputs. How~ver. (he datil ofinJiv;dllill.~l av('s are consi,rent. If an a~~~"S error occurs when updating th" panial process image ot"the outputs. the data of the faulty modules are not tran<milled: thcy rcmain unchanged in the partial pro~ ~ ss IIllage. Updating of th~ unaffected Illodules is d istributed between two DP cycles (coru;islency warning).

ately effective following downloading. thrn;e

for the DP components following the next stllrmp.

21.9 Handling Inter ru pt Even ts


The sy,lem functions for d isabling, delaying and ~m,bling affect all intetTllplS and all asyn ~hronous "rors. System functions SFC 36 to SYC 38 are provided for handling synchronous errors.

2 1.11.3 Configuration of Synchronous Interrupts with STEP 7

C~'de

Configurat ion of synchronons cycle inl~rr\.lplS i. carried out using the Hardware Configuration tool. Open the sclected CPU with EDIT ...,. OIlJECI' PKOPUtTlFS and select the "Synchronous cycle inlCrrupts" tab in thc prop~rtics window whi~h IS thcn displayed. The der:",1t priority is 25. You can set the ptiority between 2 and 26. Priority deselects the interrupt. Synchronous ~yde interrupts which I",vc bc~n 'ksc lected cannot be "ccuted. even if the corresponding on is pre,em. In addition. you assign the isochronous DP master system and the involved panial process images to the intcrrupt OB.

21.9.1 Disabling Hnd EnHhllng in terrupt . The follow ing system function' "rc available fo r disabling and enabling interrupls and a syn chronous errOl">:
~

SFC 39 DIS_ IRT Di,able intermpts Enable disabled interruplS

> SFC 40 EN TRT


Table 2 t . t ) lists the paramel .... r' for the se sys t~m funct ions

You must also set lh~ constant bus cycl .. tim es and isochrone mode on the corr"sponding 01' components (sec section . "Con figuring c<Jnsl;.tn l bus cycle times and isochrone mode"' in Chapte r 20 .4.3, "Special Functions fo r PROFT_ B US Dr"). When saving the hardware configuralion. STEP 7 "'TItes the ~ompikd data into the object System data in the om inc user program Bloch; You ~an down load the parameteri /ation d"ta 10 the CPU from here in th e STOP stalus. The parameterization data for the CPU arc immedi_

SFC 39 DIS_IRT Disabling interrupt.


Syste m fimction SFC 39 DIS_ IRT disables servicing of n .... w interrupt, and a,yn~hronous errors. All new intctTllpI" "nJ asyn~hronous ~rrOrs ar~ r~jecled. If an im~'1TUpt or a,ynchronous error O~curs following a Disable. the organi:.:ation block i, nOt executed : if th~ OB does not exi.'!. th~ CP U docs not go 10 STOP. The Disable remains in forcc ror all ptiority classes until it is revoked with SFC 40 E N IRT. A fter a cold or warm restan, all interrupts and asynchronous erron; arc e nabled.

2L9 Handlme I.IIrerrupt Events Tobie 11 .1J SFC Porame\erI for In.errupl HondIinS

The MODE and OI:l_NR parameters are used 10 specify which interrupts Rnd lI~ynchronous errors are to be disabled. MO DE - B"1 6#OO di""bll:$ lI l1 imarupts and asyno;hrunom errors. MonE '" R"16itOl disabletl an inlcnupl cl ....s w~ first OB numm is spified in the 08_ NR parameter.
Fore~ ampk, MODE-B/*16#Q1 brnlOB_ NR s 40 disables all hardware int~mlpl S; all - 80 wOllld dj""hle all asynchrono l15 C1'rors. !>10D"E .. BII 16#02 di .... blcs the interrupt OJ asynchro_ noliS error whose OB Qumber you tflltred in the OB_NR parameter.

21 .9. 2 Oelaying and Enab llnLo: In t~rruptli The f"'llowiEcg ~Y"cm functions an: available for dcLayinll and cnablinll interrupts and asynchronous ClTOTS:
:> :>

S FC 41 DIS AlRT Delay interrupts SI'C 4 2 EN_AIRT Enable dciayed interruplS

Table 21. lJ lists !.he parameters for these sys_ tem functions.

CfltCT$

Reprdk-s. of a Disable. the open.ting syslem each neW iOI~"1TUpt or asynchronom error in the diagno<!ic buffa-.

SFC 41I)1S_AlRT
Delayl n \l lnterr upts
Sy~tem function SfC 41 DIS_ ATRT dcl.ys lbe servicing of higher-priority new imcmlpTs aod asynchronous CrTors . Delay mcans that tbe ",peratln\: system saves the interrupts and a,yncllronou5 errors which occurred during The d~lay and ~crvices thcm when !he delay interval ha~ expired. Once SFC 41 has been called. the pn!1P"""' in The current organi7J11 ion bloc'" (in the currenl priority class) will not be inlcrroptcd by a higher-priority intcmtpt; no intcrropts or asynchronous =OI1:i arc lost.

Sf"C 40 I';N"_IRT Enublln2 d isab led IntHrup's


SyS\~-m funcliou SFC 40 E~_IRT enables the inlomupll' and asynchror>Oui error< di~abled wilh SFC 39 DIS_IRT. An intcrropt or asynchronous error occurriog aflLT the Enable "'ill be serviced by the associated OJaILization block; if that organizalion block is nor in tbe user program. tbeC P!: goes to STOP (except in the cUe ofOB 81 "Pov.cr suppl y erroI1:i"').

The ~ODE and Oll_I'R pM,melers srecify which imerrupIs and asynch!\ln",us errors are to be mabled. MODE " B'i 16-""iOOenables all intcr_ ruplli and asynchronous ~"TTQn. MODE WlI6iI01 enables an interrupt class whose first OB number is specified in lhe: OI:l_NR parameter. MOnl: .. 8#1 61102 enable~ the interrupt or Bsynchronom error whose OB numhcr you entered in the 08_ NR parameter.

A deJay remains in rOT!.'C until the currCllt 01:1 has tCTm inated its excc ulion I)r unlil SFC 42 E:-J_AI RT is called.

Vou can eaU SfC 4 1 s.c:~eraJ limes in 5UCCCSsiOll. The RET_VAL parameter sho"'s lhc number o fcal1.i. You IDU" call SFC 42 po:<:isely the same nllmber "'f times as src 41 in order to reenable the inlerrupt~ and asynchronous errOrs.

21 Intcrrupt Handling The SFB 54 RALRM can bas ically be called in ,,11 organizati011 blocks or ex"",ntion levels for aU ~venls . Tfyou eall it in an organization b lock whose start event i, no! an interrupt from the II O. correspond ingly less informat ion is available. D ~~ndi ng on the respcCli v ~ organi zation b lock and the component, triggering thc imerrupl. different information is ~nlered into the targe, areas .pccifkd by the TlNFO a nd ATNFO parameter~ (Tabie 21 .15). The target area TThTO (task information) contain, thc complete Stan information in bytes 0 10 19 of the organization b lock in which the SFB 54 RAL&\1 was called. in<kpC"lldcnt of the n esting depth in which it WaS call ed. Therefore the SFB 54 RALRM partiaUy replaces the SY8tem function SFC 6 R D_ S1NFO . Adm inis tra tion information (e .g . wh ich componcnt triggered the interrupt) is pre",nt in bytes 20 to 27. The [argct area An-TO (interrupt information ) contain8 th" header infoIDlation (e.g. !he number of receiv ed bytes of supplementmy interniP' infonnation or the type of interrupt) in by":s 0 [0 3 ami the component-specifIc additional intcrrupt in fonnation itself in b)1es 4 \0

SI"C 42 EN_A IRT EnMb ling delayed interrupt, Sy.tem function SFC 42 EN A fRT rocnablc. the interrupts and async'hTO"ou~ ~-n-OrS delay"d with SFC 41 . You mu,t call SFC 42 p rccbdy the same number of times as you caUed SFC 41 (in the current OB). The RET_VAL pam m eter show. the number of delays ,till in force; if RET_ VAL is = O. the interrupts and asynchronouS ~TIors have been reenabled.

If you call SFC 42 w ithout having fIrst c alled SFC 41. RET_ VAL contain8 the value 32896 (W#16#8080).

21.9.3 [{eadlng addirinnal IntcrrUjl! Infor mal io" The system function block SFB Sot R,.\LR M reads addition"j interrup t information if present - from the componcms (modules Ot" .ubmodulc.) lnggeling the inten-upl . The SFI:l is called in an imcrrupt organization block or in a block called wilhin this. Procc>sing of lhe SFO S4 RALRM is carried oul syn~hronou,ly. i.e. the requested data arc present in the output par..metcn< immediately following th~ call. Tablc 21.14 lists !h~ block paramete rs of th. SFB 54 RA LRM .

223.
The assignment of the MODE paramekT Mfine s the operating mode of SF B 54 RAL&.\t. W ith ",lODE - O. the SFn shows '

T~blc

2I 14 Paramo,"r.< ofSyst= Function Block SFB 54 RALRM Declaration INPUT


DataT~
Comem~.

ramm~ter

p.,,,,n p'ion show, t he component trig~~ rin g t h~ in terrupt 1 - "Tite< all output paramet er< 2 - ch~ c b whether tho .d~cted com po""nt ha. trijlS~",J Ih~ mtc-rrupt

MODE

INT

Opa.lin mode :

,m
MLE."i
,~W

INPU T INPU T INPU T OUTPIJT OUTPUT OUTPUT OUTPUT OUTPUT

DWORD <NT BOOL DWORD DWORD


,,~

Module <taTting: aJJ",,, uf component to I>< "'lUled .\-I .... imum n u mber ofh ,~e, of .upplementary intc-rrupt injimru.lion 10 be scanned TRU E - a n eW interrupt has been receiveJ Error i<kntitication Module
,t:artin~

SlATUS

m
LEN
TIN,"

aJdrc", of componen t triggeri ns tho interrupt

Number of h)-~e" of received supple mentary interrupt infortlliltion THfj(d orea for O il start info rmat ion and adnlini.lnltiun intonnat io n Target for beader infortnation and .upplemen tary interrupt infurmation

A1NFO

~" ~"

or".

21.9 Hand1ina lmelTUpt


l)r.blt l l .H
Admmi.tn

E~cnts

nonmfurwo 000 0", 19

="'"

Header inf",,

SUl)I)lemeotary

inmrurt1.
.... t.""
",~ 4 to 221 I'

By""

!j}1e$

20 to 27
~,

By"'" 010 3 ) '

"

,.

,.
"

you tile component lrigg~ring Ihc intClTUpl in tbe 10 pantmeter; NE.W is a... ign! TRUE. With MOT> ,... I, all output parameters are writ\l'Tl. With MODE - 2, you check wheth~r the comp<lnent ,pc~ifi~x1 by the F_ ID pammcteT "'11~ the on~ tril!l!cTing the iut~'TTUpt. If Ihis is the cue, th~ NEW parametC'T has the value

TRUE, and all other OUTpuT par.tU1CtCT1t are wriTten . In oniC1'TO work correctly. the SFB 54 RAt.RM requin:s its own instance data for each call in the \'.rlOUS orga nization block~, e.g. an own instance dam block in c"ch casco

22 Start-up Characteristics

22 Start-up Characteristics

22.1 Gen eral Remarks


22.1.1 Operaling Mode.
Before the CPU b egins procc ,sin;: lhe main program following power-up, it executes a slmt- up ro"t;ne. START_UP is one of the CPU's operating modes, as is STOP or R1.JK. This chapter describe s the CPU's activities on a Imnsi tion from and to START-UI' and in the restan routine itself. Following power-up <D, the CI'U is in the STOP mooe ( Fi gure 22. I). If th e mooe seJeetor un the CPl}'s front pa nel is a t RUN or RUN-P. the CPU switches tu START-UP mode@.the n 10 RUN mode @ . If an "unr~coverab l e" error occurs while the CPU is in START-UP or RUN mode ur if you position the mode selector 10 STOP, the CPU reUlm. to the STOP mode

\Vhen Y<J" parame terize the C PU, you e an define restan characle rislies with the "Rest an" tab such a, the maximum penniss ible amount of time lor the R eady s igna t. from the modu les following power-up or wbether th e CPU is \ 0 stan up "hen the configurmi<Jn data d<J not coincide with the a e lual configuralion or In whm mode the CPU restart is to be in . SIMATIC 57 has three reslart modes. namely cold rena,.t. ",arm re~t",t and hOI restart. On a cold restan or warm r~start, the main program is ,dways processed from the h~ginning. A h ot restan reSUmes the main program at the point <Jf interrupt ion, and "fin ishes " the cycle S7 CPUs supplied be fo re 10/98 have wann restart and hOI restan.

The u"er program is tested with breakpoints in single-step operation in the HOLD mode . Yuu can switch to this mode trom both R UN bnd START-UP. and return 10 the origina l mode when yuu bburt the test 0 Yo" can a tsu s~t the CPU to the STOP mode from the HOLD mode@.

You can SC,1n a program on a single_sh<Jt basis in START_UP mode. STEP 7 provides organization bloc k s OF! t02 (c<Jld restan). OB 100 (wann restart) and O B 101 (hot restart) ~xpressly for thi s purpose . Sample applie"tions are the paramet",ri :.:ati"n ofmodul~s unlcss thi s was already taken care of by the CP U, a nd th e progranllning of de fault, for your main progmm .

Power-up

-----<D------+

STOP

+----@-- ~~== H=O='::O::::,

__--'"--+

RU'

L -_ _ _ _ -.------~~------H!,:ure 22.1 CPU Operating :"'[ode<

_____~

22.1 Genenll Remarks

22.1.2 nOLI> Mudt

The CPL ehaoac, to the HOLD mode wilen


yOUtt'!<t lhe ptUpm with breakpoint~ (in "~'n Gic-$ttl1 mOlkn, The STOP LED Iben lights ul1 and tile RUN LU) blinks.

In HOLD mode. the oUlput modul~. ar~ disabled. Wriling to the modules affects the modul~ memory. but docs 1I0t switch the sianai stute~ "'oul"' to the module output.!<. The module! arc POI rnablcd until you exit the HOLD mode. In HOLD mode. C'O'erything ""vin~ to do with timiog i~ discootinued. This includt'!<. fOf example. the prucCS3ing of ti"",rs, clock memO!)' and runtime meters, cycle time monilorina and minimum scan cycle time, aoo the ... rvicing of Iime-ofday Wld tim<;-delay inlerrupl~. Exceplion: the re31-lime clock cOIltinues 10 function
normally.

in OB 102 or in OB 100. you mu.t load tile signal slatc~ from the module using direcl access. You ean th~'1l SCI !be inputs (transfer !hem. for IDstance. with load statements or with Ihe MOVE box from addrc"" lIll:a Plio address area then wor\:: with the inpllts.

n.

On " warm restart, Ihe "old'" procc5~-imagc it'pm and process-image OUlput tables, w hich wcr~ valid prior to power-down or STOP. lire IIsed in OB 101 and ;n the remainder of th~ cycle, AI the end of Ibal cycle. the processimage output table;" U1UISferred to module memory (but not yet switched through tu the external outputs, sioee the output modules are still disabled).
You now bit'" the option ofparumclCri?ing Ihe CPU 10 clear !bc process-image output table ltJld the module memory at the end of !he wann reSlan. Before ,witching 10 08 I, the CPt:" revok~s lhc Di&llblc signal roo thai the signal stale, in Ih~ mooule memory arc appl ied to the external outpu".

Every lillle lI,e progfCssion i. made to the ne:ott statement in te~1 mode . the timers for the dura(m of the single SICP run " little further, Ihll, simulating a dynamic behavior similur to "normal"' program s.:anning_ In HOLI) mode. the CPU i, capable ofpa.:ilvc

cOl1lmunication, thaI is, it can receive

glob~l

data or take part in ihI: un ilateral el<change of data.

If the power fails ",-hile the CPU is in ~IOLI) mode, bant;l)-bachd CPlJ~ go to STOP on power recov~ry. CPlJ& withou! backup balLcriC6 ~XOC\lte lin automath: wann n::<tart. 22. 1.3 DluhUng the Outpnt Modulu In the STOP lind HOLO moJ~s, moouk. a.rc disabled (00 (OUtput disable) .ignal). Dir.abled output mtxlulC6 oUlput a 7.ero ~ignal or, Wtbey tn..'e the capability, tm: rcplaccmcm value. Via a vurfuble table. yuu can control oUlputS 011 the modules "'ith the 'Isolate PQ" function. eVeIl in STOP mode. Durilli restart, the oetpul moouks J\."lIUIin dlSablee!. Only when the <"yelle scan ~giJU are the 01lll1U1 modlllt:S CIIabkd_ On a cold !"CSlan (Oil 102) and warm restl'" (OB 1(0). the process images and the module memory lire cleared. lfyou want to ,~an inputS

00 a cold restart. the CPU caUs organizal ion block 08102; on a "'arm restart. it call~ organization block 08 100. In the abKocl! or 013 100 or OB 102, the CPl; begins cyclic program e~eeulion immediately_
On

a \'.. ~rm renart, Ihe CPU cDII~ "'Baniution block 08 101 on a single-.hot basis befote procer.sing the main program, If Ihc....-: is no O!J 101, the CPT; begin' scanninll at th~ point of inl<"TIUption,
The start inform"tion in the lempornry local daIS has the ,arne form81 for the roIOtatt organization blo<:ks: Table n .1 .hows the SIan informatiuD for OB 100_ The reason for the: restatt i. shO"Oo'l1 in !he =tart ro:qu~t (Byte I):
B1#16~1

Manual wann re!ltar1 (OS 100)

tJ.>Il61182 Antomatic WlIrrn restart (Oa 100) 81116/183 Manual hot rest:ar1 (OS 101) B.~ I6wM4 AulOmatic hot re,11ln (O t! 101) BII16.'.185 Manual cold restart (OB 102) 1311-161186 Automali ceoldrc~lart(01lI02)

22 SlImllp Characteristics
read the Cl'U infom.at;<)n with a prognunming device in order to localizc the problem.

The ""robcr orthe stop ""ent and the additional information define the TeSta" m","" precise ly (tells YOII, for cxample. "bethera manual wann resta" was initiated via the mode ~elector). With (his infnnnntinn. you can develop an ~ppropriate e,ent_...,lated restalt rolltine. NOle thpt no a.ynchrunous system blocks can be proces.e<J in the s(anup program o f an S7300 C I' U. YOII can , et or re, et outp utS in the proces~ iml!ge in (he st artup program. hut thc tran~ mi!<Si on to thc output module~ only take< pl ace when transferring to RU:-.r mode.

In STO P mode. the user pt\I,,'1"ftITI is not scanned. The CPU ...,tric,c. the sctting~ - ei(hcr the ,,,,lues which YOIl ell(e\"ed in the hardwacc c<>nfiguration dala when you para.nteleri~ed the CPU or thc defaults - and s~ts lh~ modules to (he spceifi<:<.l initi al _,(alc_ Tn STOf' mode, (he CPU can rcc..,ivc g lobal data, ia GD conununication and carry out pas_ si"e unilateral communication functions. The rcaltime clock keeps runninll.

22.2

Pow~r-U p

YOII can parumeterize the CPU tn STOP mooe, for instance you can also SCt tbe MPI ad dress. \r.'Insfer or modify the llser program. and execUie a CPU memory l"CSet.
In

22.2. 1 STOP Mode Th e C PU goes to STOP


iMtaneC!l:
~
~

the following

22.1.1 Memo ry Ren t


A memory resct >ctS the CPU to (he in it ial state". You Can initiate a mcmory ~sct with a pT\)gramm ing device o nly in STQPmode or with (he mode sdeclOr: hol d the switch in the MRES position for at l~a'l J seconds then relense, and ancr a maximum of J ~onds hold it in the MRES position again for ~l lcast 3 5econds.

When the CI'U is

switch~d

on

When (hc mode se!cctor is set froDl RUN to STOP W hen pn " unrecovemblc' erIor occurs duro ini,l progrum scanning W he n cuted
~~tem

~ ~

funC T ion SFC 46 STP is exe

When reqll<'sted bY:ll communication func t;<>n (~top request from the progIllmminil device or via communication fUllction blocks from another C PU)
a\~o

lbc CI'U cntc~ the reason ror the STOP in the


d iagnostic buff"T. In this mode. you ean

The CPU ernses the entire u.cr program both in work. memor), aod in RAM lood memory. System memory (for insUlDCC bit memory, timers and counters) i. also cras~..J . ...,gardles~ of retentivity sening'_ With :II miero memory card. the cont~nt. of the load memory are ...,tained during a memnl")' reset.

, ..

"

22.2
The CPU S<:1lI the paranlCrers for .11 modules, including irs 0,,"'11. ro their derau!! values. The MP[ parameters of the first interface are an ucq>rion. 'f1lcy are not changed so thar. C PU whose memory luis been reset can srill be addressed en rhe MPI bus. A memory reset alsc does DCr affCCl rhe diagnosric buffer. 1M reol Lime clo<=k. or thc runrime merC1"S.
22..2 .4 R t lenlh"lly

p(nIo~rUp

A memory area

t~

retentive when its eonlem.

a: !"Ctained c"C1I "'-Mn the mains pO...... is


switched off IS ,,-el l IS on a IJ'Insirion from STOP m RUN following power. up. In the ea"" of th. CU~II\" 57.300 CPUs. mentivil), i5 implemented .... ith & mien) memory card. In lbe ea'. of Lhe S7400 CPU . bailer')" backup is required fur J'l:ttlltivity.
Reten!ive memory =85 may be Ihose for bil memory. timers, counters and data blocks. The 1<'D8th of the reLtIlliv. areas dcpcnd~ on the CPU. You can $pecify the nnmber of rel""r"'e memory bytes, timers and COunteT5 via lb. "Retcntivity" lab w!>crt you parameteri7.e the

If. micro memory card or. memory- card " 'ith Flash EPROM iJ insem'll. lhe CPU copies the
user program from rhe ,l"\Cm(Iry eard to work memory, Th. CPU .lso copies an)' config ........ tion data ;. finds on the memory can!.

22,2,3 Reltorln\: the raclIlry ... lIlng,

In 1M case ef M\O'er CPUs.. you can rCSIOl'e the

CPU. Tbe contents ofdauo blo<=ks in the RAM cun al


so be rctCTIli\~. The nallable retentive ...... i. CPUspecific . You can doflll. tbe retentivity of a data block with Ih. block propeny NOIIRe. ra;" (S Chapter 3.2.3 , MBlo<=k l'1opcnin'. With the 57300 wilh micro memory card. th. bit IDCmones, timers and eounlers SC1 as ret"" ti"e welT as the user prognm and user data aTO saved on the micro memory card. where tbey an retent". C"CTI without a haUeI)' backup. With.,..11m ~wt. !he non memi"c bit memories. time", and counters are deleted. The conrents of data blo<=ks declared as MTIOfI rctenlin" are initialized during. warm resUU1 (loaded with the inilial "a1ue< from 10M! memo ory) or set 10 lmt if a load memory objecl is nol

factory settings with "Reset 10 faclory set


ting~".
I>

Procc-:d as follow"

Swilch off the supply "oltage and Tl:move the micro memory can! or the memory card. Hold the mode selector switch in the MRES pooitiQn and switch the supply voltaiC on

I>

&.

again.
I>

If the LEOs Sf (57300) or INTF (57-4(0). FRCE. RUN and 5TOP flash slowly, reJeas<, the mode ;;electol' switch again. set ;1 10 MRES again within 3 s. and hold it in this p<>sinon. Wait until onl)' tile Sf or INTF LE D flashes. Durin& this lime period (apptfU. 5 s), you can abort the procedure by relusing the mode ..,Iector.

~"""t.

t>

I>

If the SF or INTr LED shews a continuous light, release the mode selcclQr switch,

The CPU searlS up withoul banery backing and all LEOs li ght up. It exccute~ a memory reset, then selS!he MPI address to 2 and the MPI data rale 10 1f7.~ kbilli. As "'-ell as the mrnKll')' rc~I. the real time clock is set ro the start dale and the Operalln& hOUB counter and diOJUlOStic. buffer a: deleted. FollOWIng this, Ihe CPU en ters the evem " Reset 10 f~ctory s.lIings" in the diagnostic. buffer. and go<=s to STOP mode.

Witb the S7-400, a battery backup i. required for retentivity. A cold R:SWI. delete. all add>ns areas, and loads Ihe USCI' progrnm and the (con figured) user data from load memory inlo work memory. With a warm restart. the ,.IUI!$ of the bil me.oories. timers and countC1"S !let as retco tive are retained: the user program and tbe user data remain unchanged .

On the "Restart" tab of th. crus, )'ou can .ffecl a restart with the follo,,'ing settings:
t>

ResHII1 when Ibe ~el configuration;s nOi the same as Ihe .croal ~onfiguralion

22 Start-up Char""tcri,tic,
A r~ start is ex~cu!ed even if the paramClCr_ ized hardware configuration d=s not agre~ with the actual configuration. Exc~ption: thc cunfigurcd PROFTBUS DP interfaccs Ill ll,t a lways be pre8ent and ready for opemt,on .
~

22.3 Types of Restart


22.3 . 1 START-LIP Mode The CPU cases:
[:> [:>

cxccu!~s

a restm1 in the following

Rc,cI uutpulS on hot restart The S7-4OO CPUs delete all proc~ss - image output tahles and all peripheral outputs during a hot restart . Disahle hot restart at mannal restan A hot restart based on manual input Or munications job is not pennissible.

\Vhen the mains power is sw itched on


\Vhcn 'he mode selector is set (key lod SWiICh: tum from STOP to RUN o r RUNPl. or the toggle switch changed (switch from STOP to RUN)

com-

Re&taT1 following POWER UI' De finition of the type of restan following power up Monitoring time for ready signal of thc muduks If the mon itoring time for a module times out. it is considered to be non -e xistent. The response of the CPU thcn depends on th e sctting "Startup when set configuration nOt same as acrnal configuration. Th~ re sult is entered in the diagnostic, buffer. This mon itoring time is important for switching on the powe!" on expansion racks or distributed
I/O.

On a reque,t from a commnnication nmction (initiated from a programm in g device or via communication function b locks from another CPU)

A ma"",,1 restart is in itiated vi~ the mode se lector or a commllllication function, ,m alltomalle restan by switching on the mains power.

The rcstan rom ine may he as long as required, Btld there i~ no time limit on its executioo; the scan cycle moni,ur is not active During the execution of the restart rouline, no inteTTUpts wi ll be serviced. Exe~ptions arc errorS Ihat are handled as in RUN (call of the r~kqmt ~nOr organization bloch). In the restan romine . the CPlI updates the time!"s. the TUn-time meter. and the rca l-timc clock. During restart, the ontpU1 moo"l",s are disabled. i .e ., o"tpu, signa ls cannot be 'ransmitted. T he OnIput disabk is only re,oked at the end of the restan and prior to starting the cyclic program.
A res tart rout ine can be aboned, for instance when the mode sele ctor is aelua!<:<i or when there is a power failure. The aborted restart routine is then executed frum the beginning when the power is switched on . If a cold restart ur ""ann stan is aborted, il muSt be executed again. If a bot rcstart is aborted, all restart IYPCS are p08sible.

M onituring time ror tn.nsf~"1Ti ng the param-

eters to the modules If the monitoring t ime for a mudu le times out. it is consid e red to be non- ex ist~'nt. Thc respunse uf 'he CP U then depends on the sett ing "Startup when set configurat ion not same a" actual confignration". The event is entered in the d iagnostics burrer. (In Ihe event of this e rror. yon can on ly paramelerize ti, e CPU w ith a higher monitoring timewithout memory reset - if yon transfer the system daw of an ~"II1pty" proj ect in which the neW value of the monitoring time is entered. so that the module pa rameterizatiun is completed within the "old monitoring time.)
~

fib'Urc 22.2 shows the activities carried out by an 57-400 CPU during a r~st"rt .

Moni(Qring lime for hot restan If the time between pow"," ofTand powe r on or the time hetween STOP and RUN is greater than the monitoring time, a hot restart is not carried out. The specification o ms swi!ch~s the monitor off.

22.3.2 Cold R ..S{an


On a cold restart. the CPU ~ets both itself and the modnles to the programmcd initial st ate.

n.3 Types of Re\;lart

HoI RHtafl

-""'''''
""'
lnitializll

Dlsablt

W.nn It"torl

( @

Cold Rutl"

{
fI'ItIduIes

~.

QUIpOJ!

"""

0UIpUl !I1oCId<Ji<ls

...

.........
,-

Reset pooc;els-im&Q&

08101 HotR. .1M

=~"Kr~
~0UI P<l \$
, .~

-.... -.....
1

R..... t~

p<O!SI outputa

non-relOOU datil ..

FIe ... ! al u"", da19

--~
w."" A_tlrt
~-~ m.ge Inl'\IIlIIble
06100

IniOOWze modules

08102
Cold It.....rt

-.~

~l
Warm Restoon

outpUt

'" _

.. /

''''''-______r.-.

-'0

,o.

001

r ---'
( STOP )
rl~" ...

-""".-.,...- II
modules

:"'O$f&r proce$lUpdate

prooest..

I I

INoge ~put tabIt

.. . . . . .
0",

2l.l CPU Ao!;~iti<s i')uring R.start (57-100)

22 Stan.up Characteristics dclct",s all dala in tbe system memory (including the retentive data), ",ails OB 102. and then executes the main program in 08 I fr(lm th'" beginning. The current program and the cum:nt data in work memory are deleted and with them also the duta blocks generated by a system function: the pro gram from load memory is reloaded. (In contrast t() tnen1()ry reset, a RAM load memory is not deleted.) I'Ihnua l co ld f"t'Sfan With neWCT CPU~. a cold reslan Can no longer be tnggered mll.n ually .... ing the mode selector. Wi th older CPUs, a manual cold '""'Stan is triggered using the mode selector if the switch is hcld in the MRES position for at least 3 5 before transferring from STOP to RUN or RUNP. A manual cold restart can also be triggered by a ~ommun;cations funelion from a proinumning device or by a system block from another CPU. In thj~ "''". the mode switch must be at RlN or RUN_P. A manual cold rcstan can always be initiated unless tbe C PU requestS a memory reset. Autonul\k cold rHlart An automatic cold restan is initiated by swnch ing on the mai ns power. Tbe cold restan is exe cuted if
!>

22.3.3 Warm

R~S larl

On a Wann restart, th", CPU sets both it<elfand the modules to th", programmed initial . tate, ernse. Ihe nonret",nt;"e data In the system m~mory, calls 08 100. and th~n executes the main program in OS I from the beginning. The cUlTe nl program and the cllrrent data in work memory arc retained, and "Iso the datH blocks generated per SFC. :-.tanual wa r m
r~nan ;nit;~lcd

A manual warm reStart is lowing instances: eo

in the fol-

Via the mode selector on the C PU on a Inm sition from STOP to RUN or RUN-P (on $7-400 CPUs with <cstart type switch, tbis is in the CRST position) Via a communiCali()n function from a PO or "~th an srs from aoother CPU; the mode ,clCClOrm U5l ]x, in the RUN or RUNP pos i. lion.

po

A mallual wann restart call always be initiated unkss the CPU requests a memory rc~cl. Automa tic warm rCSlan An automatic wann resUirt is initi ated by switcbing On the mains power. The wann rC$!an is e:<eculed if
:>
I> I>

the C PU was not at STOP IOoheo the power was switched off the mode sel",ctor is al RUN or RVNp the CPU was interrupted by II. pow",r outage wh ile executing a wann restan "Complele restart (warm restart)"' Oil "start following POWER up" is rmramctcrized

the CPU was not at STOP when the poWCT w~s switched otT

eo the mode selector is at RUN or RUN-P eo the CPU was interrupted by a powu outage while ueeuting a cold '""'~tart eo "Cold restart" on "stan followlni POWER UI'" i~ parameterized When operated "~thout a backup ballery. the C PU e:<ecute$ an automatic non-ret",nti .. e wann rest~rt. The CPU startS th", m",mory reS\'t automatically, then copies the user program from the memory card to work memory. The memory card must be a Fl ash EPROM.

I>

lfth .. re is a testan type switc h. it n."TJUIins without effect in the case of automatic warm restart. Ir t.hc CPU contains s. micro memo!), card, it reaclS exactly like a CPU wilh backup battery_ Wben operated without a mIcro memory card and withoU! a backup battery. the CPU executes an 3U!omaric nonretentive wann restart. The cpe starts the memory reSet automatically, then copies thc uSer proinlm from the memory

22A
card to work memory. The memory card mmt be a Flash EPRO:-'1.

~rtaininj.

Module Address

(SFB) from anothcrCPU: the mode SC'lwor mUSt be at ItUN or RUN-P.


A manual hot remIt is poSsible ol1ly whc~ the hOI rt'stan disable wu revoked in the "R ~start" tab when the CPU WaS plnImctcrized. The c'\l'ie o f the STOP must have ~n a manual activity, eith",. vi. the mode selector or through a communicati on function; only then can a manual ....arm rt'start be e~ectl\lld while the CPU i. ~t STOP.

22,].4 1101 Retllrt

A hot rtan is po"sible only on an 57-400. On a STOP power outage, the CPU saves al l intnrupts as "'1:11 as the intcmal CPU rt'gi.ten that all: imponant to the processing of the user program. On a hot restan, it can th=fore rt'sume at the location in the program at which the intemlption (lCCurred. Thi. may be the main program, or it may be an intemlpl or =or handling routine. All ("'old") interrup\.l art' saved and will be serviced. The S<K".lled """,idual cyclc. which c?ueod. from the point at which the CPU rt'sumes tile pn::li='! following a hot resta" to the end of the main ~ counu lIS pan of the restart. No (new) interrupts are llerviced. The output modules an di!Jllbled, and an in their initial State.
A hot restart i. pmnittcd only wllen!hert' ha,'c betn no Change5 in th~ ~r program whIle the C PU was at STOP, iu.;h as modification of a block".

0,

,\utomatk hOI r .. tarl

An automatic hot rt'start is initiated by switching on thcc mains pow",.. The CPU executes an automatic hot restart only in the following Instances:
t> t>

lfit was nO! at STOP when .wi tched otT If the mode 5Clwor was at RUN or RUN-P when the C PU was switcbed on

t>

"Hm rt'start"' on ~Slart following POWER UP" il parameterized

t> If the backup batt~ry is inserted and in working order


The position of the restart switch is irrelcvant to an automatic hot restart.

By parurtt1erizing the CPU accordingly. you can .pecify how long the interruption may be for the CPU to still be abLe 10 Ul:Cute. "'"llf11l relitart (from 100 milliseconds to I hour). lfthe interruption is looger. only a cold or warm reStart is allowed. The length of!be intnruption is the amount of time be""een exiting of the RUN mode (STOP or power-do""n) ..00 reentry into the RUN mode (following e;.;ecution orOB 101 and !he resIdual cycle). Mlnull IIot ,."llrt A manual oot R"Start is init iated
t>

22.4 Ascertaining a Module Addrl'1i$ Sianal modules. o. to be more cxact the u",r data on inpulloutput modulcs, ~ Bddresscd in two mannen: you use the logical ~dd"u in the UilC1" propm to a~ the inputs and outpuls. Tlli. colT"sponds 1.0 thc absolute addreu, and ~ be made easier to rt'ad by uling symbol$. The smallest logical addrees is the ~ address or module Starting address. The CPU uses the googmphieol add~ to address the modules. You rcquill: the j:oographical address if )'00 ",i.h 10 fmd OUt the slot number of the module. lbis applies similarly to the user data on 5tatiOM of the distributeO 1/0. You can use the following system blocks 10 ascertain the &CQgf1Iphical addll:ss from ~ lOllieal address and vice versa:

]fthc mode selecto. was at RUN or RUN-P ""hen the C PU ""as switched on by m(wing the mode selector from STOP to RUN or RUN_P when the,..,.tart $w itch i. al WRST (only possible on CPU, with =tart type switch) Via I communicatIons function from. pr0gramming device or with a system block

t>

22 Stan-up Characteristics SFC 70GEO_LOG AS(:~'Ttliin logical base addres~ S FC! (1AOR_LGC A5Ce.181n logical addre~s of a module channel S}-C SORD_LGADR Ascertl<in "jj logical addresses ora module SfC7 ) LOG_GEO Asccnaill geographical address SFC 49 Lei('" _ G AOR Ascenain $101 address of a module
b~ address of Lbo;; submodule. With SURSLOT - 0, th .. diagnostics address ofthc module o r station is rerum~d,

I>

I>

I>

SFC 70 GEO _LOG replaces Lbe SFC ~ GADR_ LGC, and Can be lL'\d in conjunction with ? ROFINET 10.

I>

SI-'C 5 CADR_ LGC Ase,," ~in th c log ical ch annel

~ddrc.,

of a module

J>

Table 22.2 shows the parameters for Ihese syslem bloc ks. The SFC ~ GAOR LGC, 49 LGC_GAOR and SO RO_ LGADR Ita"e 10 lD amJ LADOR as ~'Ulwnon parametcr!! for the logical address (address in the 110 area). 1010 is either 8 #16,1:54, whieh stand. for the pt'ripherul inpuis (Pis) or BII I6#5 5, which .Iands for the pt'ripheral OUlputs (PQs). LADDR ~"llIuins nn 1/0 address in thc PI or PQ area whkh eolTt'~pollds to th.., sp"cifi..,d challn~ l. T flhe channel is O. it is Ihc module Stan addr~ss. With the SfC:s 70 GEO_LOG and 71 LOG_ GI:::O, the logical ad dress is on its own in the LADDR parnmeler. A difl~remiation is made in bit IS as to whether the address is assigned 10 an input (m 0) or an output (= I). For lhc: ....J<Jrc~~es determined using the~ sy~_ t<:;m block$. an MSilPllDcut must hne been made using the lIardware Configuration tool between logical addre~s (module ~ta"ing address) and ,.I<>t address (location o f module In a rack or in a .u ti o n oflh., dislributed (10 ). SFC 70 LOG_ CEO Alcertaln the [oa:kal ha . .. add rus System runeli"n SfC 70 LOG_ GEO ~rums thc logica l ad dress of a module or station. Thc 8$sig n menl Of Ihe MASTER parameter indicates whelhc-r the station Or module is in~~T!~d in a rack (X"nLra l design) Or whether the s\$lion is opCrtued in H j' ROHH US or PROF~"'ET s)<.tern. UI><;: Ihe SLOT parameter to specify the slot Dumber in the rack Or station. and thc SUBSLOTpHl"\lmctcr forthe "umberol"the .ubmo<!ule. T he LADD R parameter th .." rctums th<l

S)"'tem function St'C j GADR_LGC rcllllIlli the logical address ofa channel when you specify thc slot addres, ("geographica l" address). Enter Ihc numbo.rofthe DP maSler ~y~lem 10 in the SUBC'I" T10 parameter if the module belongs tn Ihe distributed VO o r D_ 16#OO i(the nlodu[e i. pluall~..J imo the central rack or an expansion rack . The RACK P"llImcter specifies the number of the r4ek or, in the case of di>lributeJ 110. the numb~-r of the station. If the module has no suhrnod,,1e slol. enter Rft 161100 in th e Sl-BSLOT paramcI"r. SUIlADDR conTain, th e addrc," offset in the module's u~cr ,l~ta (W,J l 6#UOOO. for ~xample. Siands for the mod ule ,taT! address). SI'C 71 CJ,:O_ L OG Asce r l"Ln Ihe g .... g .... llhlul.ddress Systcm function SFC 71 G EO_LOG relUJ1I.S the geographical ~ddress of a moou!e or station if you define thc logical base liddres5. The value in the AREA parameter dcHnes Ihe ~ystem in which ' he module is used (Table 22.3). 8fC 71 GEO_LOG replaces the SFC 49 LGC_ GADR and can alsu be used;o B~sociatiOJ\ wi th PROFll'.'ET 10, S FC 49 LCC_GADR .o\sccnain th e ~ IOI .ddrcn o f a module SFC 49 LGC_ GADR retutlu Ihc slot ad<Jrcs~ o f a module when you specify an arbitnuy logica l mooule addres;; . Subtr-. cllOg the addr.::ss offset . (parameter SlJBADDR) from the specified user data addre3S gi'es)'Oll the modulc statlin g addre, . The value in Ihe AREA parameter spccifi~s the "Ys!cm in which the mod,de is operated (Table 22. 3).

22.4 A:;cer\ainiDg a Module Add,CjS

- crul-alL'O - PROFffiUS DP

22 Slarl-up Characteristics
Tab le 22.3 Meaning of Output ParameteTS "f SFC 49 LGC- GADR and SFC 71 LOG GEO

AREA

System S7_400 S7-300

Meaning of output parameters of SFC 49 LGC GADR RACK - rack Dumber SLOT - . 10t numl>er SUHA DDR _ differeuce from base addreo<
~CK

DiS!ri b"ted
00

Meaning of outpm parameters of SFC 71 LOG GEO MASTER - Q STATlO:-; - r.ck number SLOT - <lot number SUBSLOT - Q OFFSET - difference from base address \Vith PROFtBUS DP, I>lASTER - DP ma"cr ,y "~ m ID STATION - station number SLOT - slot number SUBSLOT-O OFFSET - di ITer=~e frum base .ddres, W;lh PROFINET 10: MASTER - PROFlNET 10 system ID STATIO", _ " otion numb<:r SLOT - . lot number SUBSLOT - subslot number OFFSET - diifet'Ctlce from base address MASTER - O STATION - rack number SLOT - . lot number of adapter casing SUBSLOT - O OF FSET - address;n S5 area

Low byte - ,motion number High byte - DP master system 1D SLOT - slot number SUBADDR - difference from base address

,
, ,

,=. " Q=. "

RACK - rock number SLOT - . lot number of adapter ~ ..in g SUBADDR - oddress in S5 area

" "

1M3 area
IM4 area

SFC 50 RD_ LGADR A. eertain Hil logical addresses fur a module


SFC 50 RD_ LGADR returns all logical addresses for a module w hen you specify an arbitrary address from the user data area. Use th e P EADDR and PAADDRpammete rs 10 detine a n arc a of\VORD components (a wordbased ANY pointer. for example P# DBzDBXy." WORD nnn). SFC 50 then shows the n umber of entries returned in these area s in the RECOUNT and PACOUNT parameters.

deviate from the default. To specify parameters, ope n the module in the hardware confi gurat ion and fill in the tabs in the d ialog box . When you lransfe the System Data. obj cct in the Blocks contailler to the PLC , you lin"' also trans fcrring the modu le param eters. The C P U transfers the module paramcters to the module automaticall y in the following cases
:>

On reslan Whell a mOdule h as been plugged inlo a confi gured slot (S7-400) Follo wi ng the "return" of a mck or a distributcd 110 station.

:>

1>

22.5 Parameterizing Modules


22.5.1 Ge neral rema r k!; Ull pHrarne_ terlzing module. Most S7 modules Can be parameterized , that is to say. values may be sel on the module which St atic and dynurnic module parameters The module paramcters are d ivid ed into static parameterS and dynamic pammete rs. You can set both parameter types omine in the Hard-

=
22.5 Paramct<!'li.zilli Modules
"'1m'

ConfigWlllion. You can al!.o modilY tile dynamIc parameLCTS al runtime b y calling '11)'1tern block. In lhe a.1aM routine, the para""'IL"" SC1 on ' he moduk~ u. ing "Y~lem bloc k& are

ovcrwrincn by the parameters ,..,1 (and

,torw

RD_REC, lhe numb<."I" of transmined byle. is presenl in RET_VAl. In Ihe C\'ctlt of ... error, Ihe nmr code i. prt"Sctlt in Ihe error infortna lion. Mod ul . And data record addreul nll
AS fur M addressing fOT data It1In .fcr iii COilcerned . Ui\e the m odule . tart w.!drc~s. With mi~ .. modu!e5 having input and outpm " ~U, -d Ule the lower area sran addl"\!SS. If you assigned Ihe same ,Iar: address to both the input BOO O\llput .....,as. u.e the identifier for an i'lpUI Bddn:ss. Usc th~ liD "Ientifier reganl l~" of whether you "'am to e ~ccu:e B read or wrile op~rnlion.

on the CP U) via the Ha rdware Configumtion.


The parame ters for the signal Tll0<.lul es are in

two dat R record ~ : the .Iati~ paramcl~rs in datu r~cQTd 0 and the dynami e para meter< in claIM record l. You Cnn lnln sfcr hath dala record s to {he module with tystem function SFC 57 PARM _MOD, dsUl record 0 or 1 w jlh s)'Stern funcliOll SFC S6 WR_f)PAAAI . and only dalll !"'Oro 1 ",nh Sf C 55 WR_PAR.',,1. The data recorus must be in the system da\.a blocks OIl tile C PU. After parumclcrizallon of an S7-400 modul e,
the spo. .;ified va luci do DOt go ;nlO foree until bit 2 ("Opu!>!;" g mode') in byte 2 of diagnO!>lic daln = Qrd 0 1m. ;wo umed 'he "RUN" The d iagnosti c data record 0 can he read wilh system fun ction SfC 59 RD_ REC or ~yst~m function block SFU 52 RDREC.

val""

The mcxhllc stan address is panrneterizcd e'ther using W IOlD and lADD R par81m1<m: or - witb nt'Wer ,y<tem bloch - using the LADOR on its own. In Ihl case. bil 15 deter mines whelher an input e'O"') or output (" I ") ;~ involved . (With the .ystem function b lo<: k.1 SFB 52 RDR EC and SFB 5~ WRREC, this il the parameter ID .)
Enter the data record number in thu REC>JU M or INDEX parameter.
Usc the RECORD parameter with Ihe dala type A.. Y 10 define an area of BYTE ~otnponen!S. ... This may be a variable of typf: ARRAY. STRUCT or unT, or an "-'''0' pointer u f type

A,y nc hro no ul pr""e.. lng of system b lod "


Apart from the ly5lCTn function SFC H R() DI'ARM. the system blocks ror module param-: eteri~.ation and lnuwni""ion of records wort nynchroooLl$ly. u cculioo ofw funct:i(ln cov, 1'" IK'ven.1 ealb , and i. uiggcn:d by the block parameter R!;Q - ~ 1-. ~uring I'r<:>CI'ssing oftlle job. the RUSY pIITlImctCT is al - I", ~d the error in fonnalion has !he value Wi!l161t7001 (job being processed). Tile error infonnalio'l is i'l the RET_VAL P[lf"4IDCICT for the ')"ltem func _ tions. lind in byt~~ 2 and 3 of the STATUS parameter for the ~y.tem func tion block s.

BYTE (for example PIoDEkDBXJ\x BYTE nnn). If)'ou u.., a ,ariabll', il must be a "COlD' plete" variable: individual lIlTlIy or 5\(U~1 .."": components are nOt penniMible.
rcrm !~ !lhle

dat a record n um ber.

A certa in job fo r a module is specified by the modu le " arting address aDd the data record numbet-. Asluni III BUSY - "1" , a renewed call for the samcjoo witll R" Q = ' "\" ba. no dfeet. and the error infonnation i . ..... to WIf L 6If7002. If an c:rror """Un! wt.cn lriggcriog an job, thi, is signaled by the error in formation. and BUSY remains "i)'". If the job b33 been completed. BUSY ba~ Ihe "atus ''O-. If the job is completed without error. the error information has Ihe value W;l16i!1OOOO; with the system funct ion SfC 59

DOla reCQrds with Inc numbers 110 24 0 nrc permi!! ihle for the system fun~lions for mod ule parameterization. The . peci ti ed data reco rds muSl be pres ent in the sy.tem data in the case of SYSI<;m block.~ SFC 54 RD_DPARM, SFC 56 W"R_DPARMandSFB 81 RD_ DPAR.

System fu""ion SFC 58 V.'R_RC can pruocss data rc<:ord< in the range 2 to 240, SFC 59 RD_ REC In the range 0 to 240. System functi on blocks SFB 52 RDRC and SFB 53 WRR EC traMmit data !"e<:ords with numbers 0 10 2SS.
Data r""QTds 0 and I ba"e a ~J'CciaJ s'Vnif,cBuce witb SThIATl C S7:

22 Stan-up Characteristics Data ,..,cord 0 : reading ufdiagnostics data (4 bytes) and w ri ting of static. module parame ters Data record 1: rca ding of diagnosti~s d~ta (dala record 0 and funh ..r data) and ,wi t ing o f dynamic module paramet<:N
~

r>

SFC 57 l'ARM :vIOD Pa rameterize nwdu1e SFC 102 RD DPARA


R .. ad prffielined paramelers

"

r>

The parameler; for the listed system bloch are de'e rib~ d in Table 22.4 , SFB 81 RD DPA R Readiug preddin ed pa rameters Sy,t.. 01 function block SfB Xl RD Di'AR transmits the Jata r<'Co rd ,vith the number specified in the INDEX param .. ter from the corre,ponJing SOU system data block to the destination an:: a specified at lhe REC ORD parameter. The transmissi on is carried ou t in asynchronous mode. and can be divided ~n.v en sev.. ral progrom cycles; (he BUSY param ctcr is " I "' during the transmission, Following 8uce~,"ful transmi"ion , th~ VALID param~t.,,- is "1" , and lh~ LE~ param~l~r contains the number of transmitt~d data bytes

A d at a recurd can be up to 240 bytes long. Module pa r am eterizat ion with I' ROFU.' ET 10 Connuction of d istri buted 110 oyer PROFTh:"ET IO requi res an .. xt~nded quantity fram ..work for th .. mo<.l u l~ paramelerilalion compareJ 10 PROFlBUS DP. and n~w syst~m block< are provide<! tor Ihis, These ne w system blocks Can ,..,plaee thc previous blocks , Fib"-ure 22.3 pro vides an overview uf th~ system bloch for module paramet .. rization,

..

22.5.2 Sy5tcm Blocks for Modul e Para m eteriza ti on


Th~

followi11g sy'tem hloch are available for parameterizing modules: SFR 81 RD DPAR Read predefined parameter:l SI'C 54 RD DPAlUvf Read prcdef UleO parameters SFC 5 5 WR PAR M Write dymuni" param eters SFC 56 \VR nPARM Wrik predcfmed parameters

The read data record can now be evaluated or modified. for example, and written into lhe module u>ing SFB 53 W RREC SFB 81 RD_DPAR replaces SFC 102 RD_ D PA RA and SFC 54 RD i'AR.\,1. SF C 102 RD Dl'ARA R~ a ding prldelined param et e rs System function SFC 102 RD_ DPARA transnUts the data record with the number specified

r>
~

C PU's memory

Module

Load memo
,S OB (SFC 54) (SFC 102) S FB 81

(SFC 55) (SFC 58 ) S FB 53

The b loch

printed in bold ')'1'" rcp l",'e the pa,-" nnhc,iz"d

1....-_/

blo.;ks 000" .
th,-m, lUlU Ulll

/
(SFC 56) (SFC 57)

.',':: ,"

,,_...J

(SFC 59) SF B 52

ah.o l:>e used 'o g.<.h~' with PROFlNLT 1 0,

'--------/
F1gu re 22 .3 Sy<1cm Bloch for M,><lul~ P;u-am eteri ntion

Tlbi.

n .4 Pan.mc'= of S~'lcm Blocks for Mooule P.....met.riut;OII

in the RECNUM parameter fmm the corresponding SOB !ystcm d"ta blod: to the destination area spcdfi\XI at the RECORD. The tran;lmiSJion is c""';ed out in asynchronous mode. and can be divi<kd belWttn 'c'era1 program cycle,; Ihe BUSY parameter ;$ .. , . during Ihe tranlmiuion . SFC 102 replaces the SFC S4 RD_D?AR.\1 wbicb works in synChronOUi mode. SFC 54 RO_ DPARM Readin.: p N! litfioed p.r.mtlcr. Sy",cm function SFC S4 RD_ DI'ARM transfe" the Will record with Ihe number specified in Ibe RECNUM parameter from Ihe relevant SOB sy.tem data bluek 10 the destination area 'pee" fied at the RECORD parameler.

The transmission is carried oul in asynchronous mode; the system function i ~ processed unt;lthe dot" record has ~n transmined. Since read ing is from load memory, tile rdatively long pro--CC'I~ins lime "'ith large data records may depcDdinS on !he application - be considered as inconvenient. In tbis CUI; use the SFB 81 RD_ DPAR or the SFC 102 RD_ DPARA whieh extcute~ this fllnction in asynchronom mode.

You can now. for example. evaluate or modifY this read d;llli record and writt it \0 the module "'itb SFFl 53 WRREC or SFC 58 WR_ REC.
SFC 55 WR_PAR!>I Wri t1ng dynamic para metus
SySt<ml function SFC SS WR_ PARM IransfCfl! the data record addressed by RECORD 10 \I>c

22 Start-up Characteristics
module specified by the IOID and LADDR parameters. Specify the nu mber of the data record in the RECNUM parameter. The data r~""ord may only contain th~ dynamic modul~ parameters . it must not be data record O. If the module parameter, are prese nt in the associated SDB, thcy must not be identified as static Wh en the job is initiated, the SFC reads the entire data record: the transfer may be d istributcd over several program scan cycles. Thc BUSY parameter i5 '1 during the transfer. SFC S6 WR DPAR.M Writing predeflned parameters System function SFC 56 WR_DPARM transfel1l the data record with the nwnber specified in Ihe RECNUM parameter from the relevant SOB syslem data block to the module identified by the IO ID and LADDR parameters. The transfer may be distributed over several program s,an cyd~ s: th~ BUSY parameter is '1" during the transfer. SFC!l7P'-\&"\1_1\100 Parameterizing a mod ule System fun ction SFC 57 PARM_MOD transfcrs all the data records programmed when the modulc was parameterized via the Hardware Configuration.
Th~

22.5.3 Block. for Transmitting Datu


Rl""Cord.

The following sy.tem blo;;ks are avaIlable for transmining data records:

> SFB 52 RDREC


Kead data record

> SFC 59RD]EC


Read data record

> SfB 53 WRREC


Write data record

> SFC 58 WR_ REC


write data record The parameters of the listed sy,tem functions are described in Table 22 ,5 and thosc o f the system function blocks in Table 22.6 , W ith an S7 -3oo CPU, you can pro;;css up to four write jobs and four read jobs simultaneously per DP segment. With an S7-400 CPU, up to eight write jobs and eight read jobs can be simultaneously active per DP segment. You can simultaneously execute a maximum total of 32 write jobs and 32 read jobs on external DP segment5. SFB51 RDREC R~ad in g u da ra record SY5tem function hlock SFB 52 1U)REC with '1 at the REQ param eter reads !he data record INDEX from the module and stores it in the destinat ion area REC01U). Th e destination a rea muSt be longer than or at least as long as the Jata record. Use the MLEN parameter to spec ify how many by tes you wish to read.

transfcr may be distributed over several program sean cycles; the BUSY parameter I S " I ,. d llring the transfer

Ta ble n.s ParnmC1ets for Sy<!= Function. U",d fOf Data Tro.nsftl

,;

J<><J

22.5 ParamC\crizina Modules

The transfer may be distrib uted over several progrnm scan cycles. The BUSY parameter is " 1" during the tran sfer.
A signal status "I" at tbe VAL ID paramC\crsignab thll the data n:cord has been n:ad without faults. The LEN panL01eter then indicale, the number of Inlnsmined bytes.
In the event o f an error. the ERROR parameter is S<.:t to "I " nnd the error information output in the STATUS parameter.

The 1Ta",[cr may be d istributed over ".,veral pr(laram SCaD cycles; the t3USY parameter is "]" during the trarufer.

S7300 deJi\"cttd prior to February 1997: the SFC n:ads ~s much data from the specified data record as the destination area can accommodate. 1bc size of the destinallOll area may oot el(ceed that of the data reconI. SFB 53 W kREC Writing a data r ecord
Sy~lem function bl""k SFB 53 WRREC with ,.\'. at the REQ parameler writes the dala record INDEX from the SOUt1:e ~rea RECORD to the modul~ Use the LEN parameterlo sped fy bow many b}1tS you wi~b \0 wrile.

The 5ySt~"tTl function block SFR ~2 RDREC contains the functionality of system function SFC 59 RD_REC, a nd can replace the laller. S FC 59 RO_R EC Rudin" Mdata ftCo rd When the REQ pllramct",. is "1", SFC 59 RD_ REC n:ads the data record addressed by the RECNUM panuneter from the module and places it in d~ti""tiOIl an:a RECORD. Thedesfination a",a must be IOllger than or at least as 1 01111 as the data re<;ord. If the trllIl.fcr is completed without error, the RET_VAL p &nomCtet contains the number of bytes transferred.

The tralllifcr may be dislribut~-d ovcr several program scan cycles. The BUSY pailItnC1er is "I" during the transfe-r. A sipl statu, .. ] al the DONE parameter sign.:l.\s that the data record hu been wrillen without faults. In !he event of an error, the ERROR parameter is set 10 "I"' and the error infonnatioll OlltpUt in the STATUS p arameter.

22 Start-up Characteristics The system function block SFB 53 WRREC contains the functionality of system function SFC 58 WR_REC, and can replac~ the lattCT. SFC 58 WR_REC Writing a data record SFC 58 WR_ REC transfers the dala record addressed by the RECORD parameter and the nutnber RECNUM to the module defined by the 101D and LADDR parameters. A 1" in the REQ parameter starts the transfer. When the job is initiated, the SFC reads the complete data record. The transfer may be distributed over several program scan cycles; the BUSY parameter is .. j " during the transfer.

23 Lrtor Handling

23 Error HandLing

The CP U rcpons ~-rrOts or faults rlete<:ted by the module, or by the CPU it>elfin different way s,
t:>

23,l Synchrouou s Errors


The CPU's ""crating system generates a syncm-onous errorwhcn an error occur<; in immediate conjunction w itn program ;;canning. A distin ction is nmde between two error types :
A progrllmminll error is pre , em if execution of the program i, faulty, Such errors include BCD convers ion errors, errors with indirect addressing : addre"ing of missing time," , eount"r, or b lo cks. Organization h l""k OB 121 is called in the evem of a progranmling error

Errors in Hrithmetic opemtions (overflow, invalid REAL n"m~r) hy 'C1ting status bits ('tam, bit OV, for exm,,]>le, for H numeri c~ 1 overflow)

> Errors detected while executing the

"',,'T

program (synchrono .... errors) by ca!l jtl& organization blocks 0 9 121 an d Oll 122
t:>

Errors in the programmable controll er which do not relate 10 progniln scanning (H,yncrn-onous errors) by calling organiza_ lion blocks 08 80 to Oll 87

The CPU s ignals the oceurrt.-'T1ee of an errOr or fault, and in wm e CH,es the c alISe, by 'ieUing crror LEOs on the fron t paneL In the ca,e of unrc<:ovcrable errors (such as inval id 01' code), the CPU goes directly to STOP, With the CPU m STOP mode, you can "'~ a programming device a nd the CPU inlonnation functions to read ant the COntent< of the blr>ek ,lack (8 s tack), the interrup t stack (1 st.ack) and the local data stack (L stack) and then draw concl usions as to the cau., e of clTOr. T he sy"em diagnost ics can dete ct error~ifau jts on the modules, a nd ,",'mers these error'> in a dia gtlo>tic bulfer. Informati on on CPU mode transitions (s uch a, the rea"ons for a STOP) are a l'!O placed in the diagnostic buff~ . T he contents of this bu ffer are r~tained On STOP, o n a tncmoryresct, and on power failu re, and can ~ read out following power n:covery and e xecution ofa "tan-up routine using a pro_ gramming device. On the ne w CPUs, you can u,e CI'U pararn"tCT_ ization to sel the llutllh<- of ent ri es the diagnos_ . tics butler is to hold.

An acrcS! error (PZF) is p 'es~" t if an attempt is made to acce" a faulty or non-existent m odule Or an 110 a ddress not known on the CPU. TIle operating system reacts in dillercnt man_ ners dercnciing On the type of access:
:>

lhe 110 access is from the user program. In this e,,",c, lhc 110 acec>s error organization b lock 011122 is called.

The PZF (}Ccurs dnring a!l\omatic updating of a (parti al) ptO<:css image. With S7-300 C PUs the defaul t "'sponse is thaI an entry is not mad~ into the diab'1l0stics buffer and an OB is llClt called; S7_400 CP U, enter each PZF into the diagnostics buffer and 't<m the OR g5 With neWer CPU., thc response to a PZt ' can b~ parameterized (sec "Program ~xccution errors 08 85" in Cnapt<:r 23.3 , "A,yn~hronous Errors").
The PZF occurs if a p artia l process image is u.pdated by" system function. The error and the address of the first byte s ignaling the error are then retwned in their param~1crs (system functions SIT 26 UPDAT_ PI, SFC 27 UPDAT_PO, SFC 126 SYNC PI and SFC 127 SY NC]O).

Tf the corresponding organization block OB 121 (lr OB 122 is not present when a synchronous err(lr event oceurs, the CPU eUlers the STOP status.

23 ETTQT lI .... dl ;ng

Sian Inronnatioo rOT the Synchronous Enor 000 12

'~~~';';';'~i~~~~~======= 1 ..
Fe: Bi;I6#8C

,
,

Bn aCCen
Brte acceSl
.....ord access

, , , ,
, ,

DoublewOTd ae,en

Process.,m"e ,npu' table I OUtpu' table Q Memory bit" M Global data block DB Instance da,. block DI Temporary local L local data orthc
Proce"imal~

doa,.

> Errorcd odd.e.. (~t rood/write oeeeSf) ~ Errorcd orcll (in the ca.., of arca error) ~ Ineomct number of tbe block. timer/cO\101er 1I.,,<:tio{)
01)
12~:

Ad<Jrt' 31 which the error occtuTe<!

Tab le 23. 1 showl the Start infonnation for botll synehrQnoU$ etTOr orgalli7.alion blocks. The S7400 CPU5 di ..ingui,h bctwc~n tWO types of acecss clTor: acce,s 10 a Don'cxislem module and inva lid access attempt to an exist ing modu l ~ (acknowledgment delay QVZ). [fa module fai ls during operalion, that module is marked "nonexistent" approximately 150 p.s after an ace~SII auempt, and an 110 access error ( PZ f ) is rccponed on every subsequent allempl to aCX:e8S Ihe module, The CPU also repons an 110 access error when an attempl is made to acecss a non-cxistent module. rccgardlcss of whether the attempc was direct (vii the I 0 arca) o r indirect (via the proo;css imaae), If an access elTOr oc<:urs whcn writing the pc:riphcnll outputS, an 57-400 CPU tracks the outplU procci>'ll image, an 57-300 CPU diX's not,

A synchronous elTOr Oil hDS thc same priority (class) as the blm:k in which the elTOr occurred, The accumulators and addn:!i~ registers of aiynchronous error 08 comain the values present in lhe block eau$ina the error at the time of aooning, The data block registers are deleted: lbe condition code word hilS an undefined content l\OtC thac when a synchronous error OB is called, ils 20 bytes ohlun infonnalion are also pushed onto the L Slack for the priority class Ihat caused the CITOr, as arc the olher temporary loo;al data fur the synchronous etTOr OB and for all blocks called in this OB, The area reserved for the temporary local data must be designed for this in e'CT)' ass:o<:ialed priority class (program ex~cution level): (fixed setting with 57-300 CPU" adjustable with 57-400 CPUs du ring

'"

I
Tobit D.l SFC Pan",.,.".. for Syr><:hronvus Em>r H.ndlma

p'~~~",""

pnmc::rization of (he CPU in the "Memory" tab).

> SFC l7 D:'1SK FLT Urunast. synchronous error


(rc-mablc DB call)
t>

11 ;s similar ,,jth !be block

depth. The nesting depth per priority ~1'!I pmnissible for a CPU ;~ the Iolal of lhe nesling depth of the "normal" proces~ing and tile nesting de-plh of
nffilflg

SFC3SREAD_ERR

Read ror register


The operating sysTem enters the synchronous error in the diaiUo.tic buffer without regard to the use of.ystem functiOlt$ SFC 36 10 SFC 38. The par"meteB for t~'" system functiom are

'he synchrom>us error processing.


In the case of 57-40(), anQlh~ synchronous error Oil can be called in In <mvr OIl. The blo<:l: nesling depth for. synchronous error DB Ii 3 for 57-400 CPUs and 4 for 57-300 CPU~.

hoted in Table 23.2.

You Can disable and cubIc I synchronous error

OB call with !;)'Stern

function~

SfC 36

MSK~

B.2.1 Error Fille rs


Th~.",.or

FLT. SFC 37 DMSl<:JLT andSfC 38 READ_

ERR.

lilleB are used W control the system !Unctions for synchronous error handling In the prograuuning error fil ter, one bit stand, for

23.1 Synchronous Error Handling


The foUO"';ng system functions ~ pro"i<kd for handling '<}'DChronous errors:
po

SfC 36 MSK_FLT M1tSk synchronous errof$ (disable OB call)

each programming error det~lcd; in the access error fiher. ODe bn s!ands for each acc~n OITOI" deucted. Wben ~ou define an error filter. you $C:t the bn that stand> for the syndlrooous error you "'aD1 to mask. unmask 01 query. lbc: error IilteB ",turned by the ~tem fllll(:tiQM show a "1" for synchronous =on that an: Ilill masked or which have occum:d.

T.b~

1l.J ACCeM Error filter

Thc BCCCSll CIT(>T filler i. shown In r .. blc 23.3; 'hc Error Cu<.!c ~olumn show. ,h~ contcnt~ of variabl.., OB I 22_SW _FLT in {he .tan infonnlllion forOB 122.

'ents of variable OBI21_SW_FlT in thc Slart information for OB 121. The error fi1t~r hils nut li~ted in the tabks arC no, relevant 10 the handling of synchrnnou,
ClTOU .

The pl'Ogrammin\l. error fill~r is shown in Table 23.4; ,he Em:>r Code cuhmm shows thc ~unTable U.4 ""Q&l1Ul1lnina Em..- FilleT

"

Ii

,,

'"

23_2 Synchrooous Error Ilandlina

U..2.2 Mn king Syncb ronous Error.


System function SFC 36 :\iSKJlT dis.ables synchronOlll error OB calls via the error filteTS. A ."]". in the error filten indicate~ lIle synchronous erron for whicb the OBs arC nOI 10 be called (Ihe synchronous ClTOI"S are masked'). The mask ing of synchronous errors in the error fihers il in nddition to the masking stored in the optt1ltinS sYltem's memory. SFC 36 returns, function value indicating wbether a (stored) masking ,Ircady exists on at least one bit for the masking specified at the input parameten (W~ 16l100(1). SFC 36 mums a l~ in the output parameun for all cum;lItly mllSked errors. lfa masked Ii}TlChro"""s error event ocrurs. the resplive OB is not called and the nror is ente~d in the error register_ The Disable applies to the current priority c1as.s (priorily level). For example . if you we' to disable a synchronous I.'ITOr OB call in the main program. the synchronous eITor OB would still be ca llw if the t'\TDT were to occur in an interrupt service routine.

If an unmasked synchronous error oceurs. lbe respeclive OB is cal~ed and the ~enl enlered in the mor "'';<ler. The Enable applielto the cur rent pnority cia" (priority level).

23. 2.4

Rud ln ~

th e Error Reghl er

SyStem func lion SFC 38 READ_ERR reads thc in the error error reiistcr. You mus' enter a mt~t1 10 indicate the "JlIchronous erro~ whose enlria; you ",anl to read. SFC 38 r<.1untS WtO 16it()(l(l1 as function value wilen the ""Icclion slN'cilied in the input param<:u,n ir.duded at least one bil for ",mcb 00 (<lore(!) masking

extsa.
SFC 38 ",rums a ~l~ in the OUlput paraml:lCTS for Ihe ~lected errors when these errors o<:cum:d. and deletes these: errors in the mor tl:1I;5t ...... wben they a,e queried. The synchronous errors that are reponed arc thOle in the current priority cla" (priorir;. le"el).

2).2.5 En tering a Su bstitu te Value


SFC 44 REPL_ VAL allows you to entcr I ubstirute ~alue in accumulator I from within a synchronous error OB. UK SFC 44 when you ean no 10nilCT read any values from a module (fot inSlance when a module il def..-.:twe). WhC1l you program SFC 44, OR 122 ('seceS! error") is called every time an attempl is nude 10acCeS! the module in quenion. When roucall SFC 44. rou can load a .uhslituto ~alue inlo the accumulator; the program. scan il then resumed wilh the sub~lirut~ value. Table 23.~ !iils the par1lmeters for SFC 44 You may call SFC 44 in only one iynchrooous

U .% Unmukinl: S)"ncb.ronOIlS Er ron .3


SYSlem fulll."tion SFC 37 D~1SKJLT enables lhe s}TlChronou5 error OB calls viii the error fil 1m. You enter a ~l~ in the filten; to indicate the synr.:hronoul nron; for whi~h the OB~ 81e once again 10 be callo-d (the synchronous errors t.rI! "umnasko-d). The entries com:.ponding 10 the srx:cifi~d bits B1<' deleted in the elTor ftgister. SFC 3i rC\ums Wli l6#OOOl as function value if no (Itor(:d) ma!king al",ady exists on at lust one bit for the unmasking sp<:cilied al the inpul parameters. SFC 37 rerums a ~ I in the OUtpUI paramelers for all cwn::-nlly masked. nrors.

errorOB(OB 121 orOB 122).

23.3 Asynchronous Errors


Asynchronous elTOfli are errors ..... hich can occur independently of the program ~can. When an asynchronous error OCCUf!\, the operaling syslem calls one of me organization blockli listed below:

gocs to STOP if the OB is cal led" second tinlc in the s!mle program s~al1 cycle. Power s upply
~ rron

OD 81

The operating system caU, organization block 0881 ifone ofth~ following ClTOn occun:
:>
Co

013 80 Timing error DB 10 Power ~upply error


D B 82 Diagnoslic imerrupt D B 83 lo scrtln:movc module inierTUPI O B 84 CPU hanl ..... >rn: fault OB liS Program execution error

1\1 !I!!m

one ba~kup banery in the central controller or in an expan.ion unit is empty No bunery volUige in tbe ccnlnol conlruller or in un expansion unit
24 V supply failed in centra l eontrolll!ror in
Bn

(>

expansion unit

on 81 is

013 86 Rack r"ihJrc 0 13 87 Conunonicalion error


O B 88
~55ing ~bort

caU~d for in,uming and outgoing events. Iflh",e is nO OB 8 1, the CPU cun linue. functioning when a power supply ~'lT<.>I" UC~Ufli.

In!H'rU"'mo .... modllie Interrupt 08113 The "P<'ntting <ystem monitors Ihe module configuration once per second. An entry is made in the dia!l:nOSlic buffer and in the w~tet11 status list each tim~ a module is insened or removed in RUN. STOP or START-UP mode. In addi tion, me o~nlting '}"Item calls organi_ zatioll block OB lB iflbe CPU is in RUN mode. Iftbcrc is no OB 83, tbe CPU goes 10 S"I"O I' on :m insen. remo~e module intcrrupt.

The OR 82 call (dia),'T1oSlic interrupt) is described in delail in Chapter 23.4. "Systent Diagnostic,",
On Ihc S7-400 H, Ih'en are three additional asynchronous errOr OBs'

O R 70 110 redundancy "Iron;


OB

CPU redundancy erron;

013 73 Comnmn icDiions redundancy errors

The call of these nsynchronous error orgam"a_ \inll blocks can be dinh1cd and enabled .... ilh iY$tem functions SFC 39 DIS_ un and SFC 40 EN rRT, and dclaycd and ~'lliIbled with $) >1~'lIl fWicuons SFC 41 DIS_AlRT and SFC 42 ~N AIRT. TIming

As much as a sccond ~an pass before the insert! remove module interrupt is gcnel1lted. As p ~suh. ,t ;s po~"ble that 1m access elTO!" or an CTTOr rcia Ullg to tbe updating of the prochS imI1ge could be reponed in ,he interim between removal of a module and g~"IIeration of the interrupt.
If B .<uilable module is inscned into a CO'ltjgured slol, the CPU autOtnUlically parameleri~es lhat module. using datu records already siored un that CPU. Onl)" men is OB 83 called in order 10 ~i8nal thai the eonnecled module is ready tor operation,

ermrs on 80

The Of"'rating system calls organization hloc);on 80 when onc of me following errors OCCUfli:

> Cycle mon itoring time excdcd (> O B requesl .mw (the requested 08 is still
executing or an OB was requc.led tOO frcquellt ly within a aivell priorily class)
J>

C PU hardwan faulU OB

8~

Ti me-of_day interrupt error (fOD interrupi time paslix:e$uSC clock was ,;ct fOr-l'ard or aner Imnsiliun 10 RU ~ )

If no OR 80 is avaihlble and a timing error occurs. the CPU goes to STOP. The Cl'U al,o

The o~rating system calls organization block OB ~ " hen an interface I'TTOr (MPI network, PROFIBLS DP) oceUIlI or di""PPCIlfli. If Ih~= is no OB 84. CPU...... ith older opemting sy~ tems 110 to STOP on a CPU hardwa..., fault.

398

Projtnl m u e.: ut ion uron 01$ 85


The opcr&ling sy>;~m eaU~ OIi"nizat ioll block

Rack fl.lI ur e O B 86
The open";ng .y~tcm can, oJWIDiation block OR 86 if it detects the fa.ilul"C of a rack (po'" cr fai lu~, line: break:, defective 1M: not with S7300j, n DP master ~y~tC!D or a di"ributed 1'0 ,tation (PROFm us DJ' or PROF1NIiT 10). 0 13 86 is caUed for both incUIJling and leaving

Oil K5 "lien one oftM foHowing errors occun:


to>

SlaTt r~u c .t for an Qrga nization block: which has nol occn Irnu.l.xI Error ",",cunni whi le W <>pI.Taling ~ystem wa~ accessing a block (for irulance no inSlance do.la block when a system runetion bloc k (SFfI) was cal lcd)
110 a.'ecss error while executing (automatic) updating of Ihe (IfOCes!l ima\:c on the system side

to>

=0.

In multiprocessor mode, Oil 86 is "lied in all CPU~ if" .... ck fails.


Ifthcre h no O B ~6.me CPU go." to STO P if a rack failure ocrun;.

to>

On the S7-400 CP Il>. 08 8~ i~ called at liD liO access .",.or on me ' ystem .idc. i. e. when updating tM procc~s image in each cycle. n.e sub.lilute value or zero i. wn enlered in Ihe rdevt&lll byte in Ihe process-image ;npul table at evcry
update.

Comnlunkatl on error 08 87 The operating system calls organizalion block 013 87 Whl-n a communication error occurs. Some e~amplcs of communicatioo errors Arc;
to

In,... l,d ftame identification or mmc length detected during alobal dala communiC/u;OD
Srndi"i of diaiiI"'Qjjlie emrie, not roniblc
Clock
')lnchroni~.alion error

On the S7-300 CP Us, 01:l8S is not called in th~ event of an I/O acee.. <:rTIlr during automatic Updat ing of tbe pl"tlC""" itruoll". AI the firsl ."TTOre<i ac~~ W suh~t itute " aluc or urn is CJ"Ile<ro in me re!evant byte; il is then no 10llger updated. With apl"lropria\ely equ ipped CPUs, you c;1ll use CI'U parnmele rinl.lion 10 in nucnce the call mode or OD !lS in W evenl of an 1,0 access error on the ~y5lCm side:
[>

t>

to>
I>

GD stalUS cannot be C1Ilc-rcd in a <lata bl"", k

If the~ is DO 08 87, thl: CPU goes to STOP when a communication errOT occurs.
P roctss la a: abort 08 88
The oremting fj"llem calls organiUlion block

01:1

8S ;5 called e..ery l i~. The affected in put byte ;s overwritten wim the substitute
v81ue: or with zero cllCh tinle .

OS 88 wbi:n proc.-ssing of If. block in the: USCI protram is ~borted . Possibl e reasons for ar"l abort includ e:
to

Wilh a

.ynchmn<l\l~

errur, the

pe-rmi~sib!e

:>

0 885 is called in the: eveot of/he first error ,,ith me annbulC iO)ming"'. An .fleeled input b>lc i. on!> overwrillen with the sub, tirute value or Wilh 1.cro the forsl tim~: follo wing Ih[j ;t is n<.> lonaer updated . If the error is then oo"""clcd. Oil 85 is called wim
the anribute "outgOiDIO": r()I1()"'ing updated "normally-.
Ihi~,

block nesting depth

j~ t':<CC<.-dcd.

> With a block call, the {>C'nni,.ible Dc.ling

deflth i,
to>

c ~c~ed.

A fault ha~ ""curred when aUOCMli ng thu local da'" of a block.

it is

[>

013 8S i. nOI caned in m~ ~venl of an ~~~css error. Affected input byt~s W"C o.. erwritten once: w;lh the sU[Ktitute: .. alue OT 7Cro, and then no longer up<bted.

lfibere is no OB 1I!1, 1be CI'U gocs 10 STOP if a processing ahun occurs. The CPU alw g~ to STOP if the OB is culled in priori ty class 28. 110 redundan cy error OB 70
The operating sy~tem ofao H CP U ~all$ orga nization block. o n 70 jf a redundaDCY loss occurs on PROFmUS DP. c. . in the cvent ofa

lJ lhere is 1>0 0 8 85. lhe: CPU goes 10 STOP on a program c~ecutlOn error.

2.3 Error Handling bus tailure Oil the active DP master or in the e vent of a fault ill th~ interface ofa DP slave. If 00 70 docs not exisi. the CPU continu~s to operate in the event of an 1 rcdl.mdancy error. /0 CPU retJ undancy e r ror OD 72 The operating systcm of an H CPU calls organi~atlon block OR 72 if one of the following events OCcurs:
t> t> t> t> t> t>

Modules with d iagnostic capabi lit ies distingui sh bet'Vttn programm able and non-pro grammable d iagnosT events. rogrammablc ic diagnostic even,s are reported only wheu you have sct the parameters necessary to e nable diagnostics. Non-programmahle d iagnostic evt"nts [I re always reponed, regard less of whether or !IO! d iagnostics have beeu enabl ed. In the even! of " reponable diagnostic event,
t> t>

T he fault L ED on the CPU goes on Thc diagno.ric event is pas<ed on to the CPU's operat ing syst em

Redundancy loss of the CPU Compari son error (e.g. in RAM , in the PIQ) St,,"dby. m~ster changeover Synchronization error Error in a SYl\'C submodu]e Update abon

,. A d iagnostic lnterrupt is generated if you havc set the parameters enabling such interrupts (by defau lt, d iagn osti c intcm'pts an;
d i sabl~d) .

[fOB 72 does not exist, the CPU continu~s 10 o perate In the event ofa CPU rcdundancy error. Communic.. tions redundancy
ctl"flr

OB 7.3

The operating system of a fault-tolerant CPU calls th~ organization bl ock OB 7.3 when the reduudancy of a fmllt.to1crant S7 connecti on is lo>t for the lirstlime. [f at \caSt one fault.toler_ ant S7 conntttion signals a loss of redundancy. thc OB 73 is nOt called again wh~n there is a funhcr loss o f redundancy. If Of! 73 docs not exist. the CPU continues to operate in the evcnt of a communication:; redundancy error.

All diagnost ic events reponed to the CPU oper_ ating syst em are e ntered in a diaKn";'lie buffer in the order in which th~y oc curred, and with date and lime stamp. Th~ diagnostic buffer is a battery-bHchd memory area on the CPU which retains its eoutents Cven in the event ofa m<..lfl ory reset . The d iagnos1ic bufter;s a ring buffer whose si.ze d epends on the CPU. When the d iagno stic buffer is full. the oldest entry i, overwritten by the newest.

You can read OUI the d iagnosti c b"ffer w ith a programmiug device at auy time. In the CPU 's S),stem Diagnos,ic5 parameter block you can specify whether you want expanded diagnostic enlIies (all OB calls). You may also spcci fy whether the last d iagnostic entry made bcfore the CPU goes to STOP should be sent to a speci lic node on the MPI hus.

23.4 Syste m Diagnostics


2.3.4.1 Diagnostic Events and Diagnostic Buffer

23.4.2 " 'ri ling Us er Entri<s in t h e Diagnos tic Bu ffer


System f"Hctiou SFC 52 WR_ VS_ \1SG wri tes an entry in th e diagnostic b uffer Which may be sent to all nodes on the MP I hus Table B.6lists the parameters for SFC 52. The entry iH the d iagnost ic buffer corresponds in fornlat to that of a sy stem event, for ins tance tht" stHn illfonnat ion for aH organizmion block. Withi n the penniss ible boundaries, you may choose your own even t 10 (EVENTN parameter) and additional information (INFO I and 1"fF02 parameters).

System diagnostics is the detection. evaluation and reporting of ~ITOrs occurring in program_ mable controllers. Ex amples arc ~ITors in the user program , module failures Or wirebreaks on signaling modules . These diagllostic e\"enls nmy be:
t>

D iagnostic interrupts from modules with thi s capability System errors and CPU mode transilions User messages via s)";tem functions

t>

t>

"'"

23.4 System OiagnostiCll


Tabl.23.6 Parameter< for SFC 52 \\'R_ USMSG

"
The event ID i, identical (0 (he f1NtlWo byt.. of th e buffer cnuy (Figure 23.1) . Permissible for a user enny ar~ the event classe, 8 (diagno tic entries for signal modules), 9 (standard user events). A and B (arbitrary user event ,). Additional information (INFOI) corresponds to byte, 7 and 8 cfthe buffer entry (one word) and additional information 2 (INF02) to byte;; 9 to 12 (one doubleword) . The contents of both yariablcs may be of the uscr', own choice. Set SE:t--'D to "j" to send the d;agnostic entry to the relevant node . Even if ,ending is nOl possi ble (be<:ause no node i. logged in orbccause (he Send buffer is full, for example), the enny is still made in the diagnostic buffer (when bit 9 of the event 11) is set) gnmuned, the CPU goes (0 STOP on adiagnostic imerrupl. You can disable or enable Oil 82 with system function SFC 39 DlS_IRT or SFC 40 EN_IRT, and delay Or enable it with system function SFC 4 1 DIS AIRT or SFC 42 EN AlRT. PROFIBUS OPV I ,laves can aho generate a diagnostic interrupt if th e ma.ter CPU is at STOP. A di.gno.tic interrupt triggered with (he CPU at STOP is acknowledged, but not processed. Calling the organization block OB 82 is nOI carried out subsequently when the CPU goes to RlF.<.'. Table 23.7 shows the start infonnation of the diagnootk interrupt OB 82. In the first byte of the start information, B#16#3~ stands for an incoming diagno,tic interrupt and B#I6#38 fOT a leav ing diagnostic in terrupt The sixth byte gives me addre5S identificr (B# 16#5 4 standi; for an input, BII16!i55 for an output); the ,uhsequent rNT variable contains the addrel;s of the module tbat genemted the diagnootic interrupt. The next four bytes contain the diagnostic information provided by that module. You can use system function SfC 59 RD_REC (read dam record) in OB 82 to obtain detai led error infonnation . The diagnostic information are consistent until OB 82 is exited. that is.mey remain frozen'. Ex iting of OB 82 acknowledges the diagnostic interrupt on the module.
A module's diagnostic data are in data records DS 0 and DS I. Data record OS 0 contain, four bytes of diagnostic data de.cribing the current Status oflhe module. The contents of these four bytes are ide nt ical to the content, of bytes 8 to 11 of the OB 82 stan infonnalion. Dam TCcord OS I contains tbe four bytes from data record OS 0 and. in addition. the module-specific diagnostic data

23.4.3 Evaluating Diagnostlc Interrupts

When a diagnost ic interrupt is incoming or outgoing, the operating system interrupt' scanning of the user program and calls organization block OS H2. If OB g2 has nOl been proEvent 10

11511411311 2111!1O!91 B 171615 1 41312 111 0I

~ Wl'',' _txaQ..,.,,, """or


EVMt
"'- ~

~umb8r

.....m

'------ ,.,'::.~'~":.:"'~.:""~-----' .
Eoftnl cia:
t OO' _ Sa",,>m "...,.."..,nl ' 0'0 . Attn.. . - . ~1"" , 0" At tho ",Of.
l (i(J()
~r.ot'1C ~mr)'

' , ' _ In,.",.t ",ror

EVMt bits
for.ignot modulo

"'w.t""

Figu,"" 23.1 Even, lD for Diagnostic Buffer Entrie,

'"

23 Error Handling

Table 21 7 Slart Informalion of Organizalion Block OB 82 (Diagnostic. Interrupl)

"~

..

,,'
BYTE
B#I6#38 ~ DQ\VN eyenl 1l#16l<39 ~ UP eyem
ETTQTc<><I ~

" , ,
,
6 ... 7

OB82 EV CLASS ~m

'YTE

~
~
~

~
BYTE
R=

,,

..

OR

R.,erYcd 1 i 10

WORl)

Module slarting addres of mod uk

..0

"'
i:i

~ ~
..
..

~
BOOC 'OOC
BOaL

~ ,
Front

, "

"' "' "

,
Module not pararneteri7ed

~~

~
I

..

, >D, ,
,0;
10.4
10. 5 10.6 10.7

-;;om -;;om
~
BOOe BOOe BOOe
BaaL

'. 1. Bil 4 channel information pr.,ent Bit 5. u'er information p~,e n t Bit 6 <ii"!!TIo>tic' interrupt from proxy Bit 7 ,..,,,,rv.. d

C(}mmuni~alion,

fa ult

statu.

..
f.iled

;ro;

Timwu' has
l>lodukm,=1

,_m

~ ~T

Flat banef)

..

,
,

11.2
)1.)

~ ~ ~HT
~C)'CT

~
BaaL IJOaL BOOL BaaL Proccs.or
f"jlur~

EPROM roul!
RAM faul!

11.4

11.5
11.6

ii-' " ~; ~

'OOe

~
OT

~'"'',
.
iIi

ADCIDAC fault

~
lime of, i

23.4 Syot"'" Diagnostk" u,inl!: ~ CPU with DI'VI cllpability and a COf1'<:spoooina ,lave. you can U'jC thc system function block SfB 54 RALR:>t to obtain fur ther inforrnation on thc diagn.tmle interrupt. 23.4,4
~ Readln~ Wh~n

SZI. ID

the

Sy~lcm ScMtu~

List

0000 - CPU
0100 - 1M
tOOO~

system $JanlS Ii." (SSL) de!cribe. the current S13tll<l of the programmable controller. Usi ng inforonation funclion~. the list C1l;) t>e rc"d bul Mt modified. Since the complete Sylit,m starn,U" is e"tremely larl!:e. r d ing is car_ ried out in subli.1S and subli.t eJltnoels. Subli.1>o lin.' vinuallil;I~, .... hicb mellllb tblot lhI:y are made a~aiillbk by Ihe CPU operating system unly on request. The SSL In ex ists in orner tn identify a ,ublist. Thi. contain. the module type cIa .. to whi~h the liil applie~, the number of the subli$t e"tract, aod the aetual SSl .ub.ist oumber(figun: 23_2). YOtl Ire providc4 with thc desired infOlmation together with Ihe index which specifi~, an object of a subl i~t. A S standard. the CPU provides infrn"lllui on on the au:om8tion system, but n... and CI' modu les can alSQ use tbis 5crVlce in ord.,.- 10 make informatiml mvail_ able (see module doc:umMltalion). The p!}'I~ib!e ,ystem nntu) li.ls for a CI'L are described ;n the operotiOll)j do~criplion . ReMdi ll g lit e huder ;nfonnHtlon U!;e the SSllD WII16#OFxx 10 ~8d the header infomlSlil,)ll of Bn SSL subli.. t witholll Ihe usoe ialed data ~co rd (xx SS!. suhlist number). The SSL_H EADER. N_ DR parllm eter (number of daJa <ords) then returns the maximum po;t.iblc number of data records of the .-ubli.t Atnoet which th .. module can deliver with all C

fLl

1100 . CF'

Figu .. 23.2 SI1U<Iur<: ofSSL ID

SSL jub. With dynamic sublists, tile va lue Cll.n be gn:atcr than the actual number which can be read. The length of" will n:cord i. specified in SSL_HEADER. ' ....ith thl' dalll in til<! heade, infurmati on. it is possible ql. 10 creale 1l sufficiently large data buffer for th e associated SSL ,ubh.1 ill the .u>.rtup_ S I'C 51 RDS YSST Read SS L . ubll51 Use .y.tem ru,,"'ion SFC 5] RDSYSST to read a ,ublilt Of' I subli,t extract or the 'Y"lem Statu.~ lisl (SSL). TIle param~'\c"" for SFC 51 arc liMed in T~blc 23.&. REQ '" "I" in;l;ale~ lhe read opct1Ition. Wld BUSY - ;'0" 1~11, you when it Il;I.S been ~om pleled. The op:rating syMe m e,Ul execute severnl asynchronous read operalions quasi ~imul llIIIeou,ly; how many depel<l~ ott Ihe CI' U being U$cd. If SfC 5 I repuns a lack o f rewurce< via the fun~1ion vlllue (WIII6#8085), you must resubmit your read request.
Th~ cont~Dl$ of parameters SSL_ IO IUId R'-I)EX arc CPU -d~pcndem. If the INDEX panuneter is nol required to provide infOl'lDlllion, iu ~s'i&nmem i, irrelevant. The SSL_

Ta bl~

23.H

~""""Cl<:rs

for SFC 51 RDSYSST

""

23 Error Handling

HEAD ER p aram e ter is of data type STRUCT, with variah l",s LNGfHDR (data type WORD) a nd N_DR (WORD) 'is compo]]"'nts. LE NG fHDR co]]tai]], th'" kngth of a data record. N_ DR the number of data re~onb read , Usc Ihe DR param et er to spc~ify th", variabk or data area in whi ch SFC 5 1 is to enter the data "",unts . For exantple, PitDD200.DBXO,O WOlli) 256 wo"ld provide an area uf 256 dam wo rds in d ata hloek DB 200, bt:ginning with D AD O. If the a rea provided is of insufficient c a pacity, as many data recurd s as possible will be e ntered. Oniy complete data re~urd , are transfem:d. Th e spccifi~d ar~a must he ahl e to a~~ommodatc at least 011e data record .

the lP address ofthc CPU in the Object l'ropertics of the PROF~ET intert3ce on the " (j~ner al" tab. The Web server a lso suppons thc Terminal Service of \Vindows ,u that thin -cli e nt ,oimions can bc u,~d w ith mohi1e devi ces or lIM! sta t;ons w ith the thin -clienl opliun llmier Windows CE. In this case, ,p~eifythe address in the I'}fin hllp.-!Iaaa.bbb, ccc.dddihasic. You call navigate to fu rther information from the 5taIT pase of the CPU. Plcase nute that the information ollcred is "ati c and you h" v~ tu prov ide fur up dat ing o f t he screen content yoursel f The c ur,..,nt intormaliun frum the C PU is nse d for printing OU1, r~gardless of what is on the display. Note : P.-oteel your Web server against un anthorized aCCeSS by mean s of a f'irewall , 23.5.3 \V.. b information The W",b server can provide the following information in a suitably e qui p ped CPU: " "
>

23.5 \Veb Ser ver


C PUs w ith 311 Ethernet interface can have a Web server that provides information from the CP U . Tu rea d out the infonnation v ia the ~um p any 's intranet or th e Internet, yuu require a ;>" eb browser, such '" Internet Explorer, Versiun 6 .0 o r highe r, th at displays the infomtalion on HTML p ages .

Start page with general CPU informalion Identific ation data Oiagnostics buff,,'! M"ssages (without ack nowledge faci li ty) PROFINET

23.5.1 Activ ating the \Veb

Sen- ~ r

Yu u can a c tivate the Web se rver when parame teri"; ]]g the CPU with the Hardware ConfiguraI.ion . Whe]] a Cl'U is sde~ tcd. EDIT --;. OBJE CT P PQP r.RTl ES selects th~ "W~b" tah 0]] which you activate the VI/e b server and s~l ect the la n g uage fnT th e me,sage texts and the entries in the diagTIuslies buffer. 11 is also pu"ib l ~ tu >elect severallanguages, depending on the mem ory capacity of the Cl'U. Th e lang uages installed with STEP 7 arc a,,~il abk You c an establish agreement w ith the languag e' in'talled in thc proj~~t in the S1MAT 1C M anager: Sel ec t OPTIU~S --;. L ANGtJAC,E FOR DISPLAY DEVICES and dcfin~ the languages , Th e W~b s~rvC1" is rcady for usc afkr the contigurmion data have bc~n loaded onto the CPU.

"
[:>

interface

v Variable status
> Vari"ble tahle,
The first p age pro vid ed by the Weh server is the Welcome page. From here, cliCk on ENTE R to reach tne Stan pa ge . If you want \0 skip this intra page in future, activate th~ option "Skip TnIrO",

Start and identificatio n Tht" Stan page ,hmv8 ynu general infonnation and th e ,tatu, ofthc CPU at the tim~ of th e q uery. The Tdent ification p age conta ins the key data ufthe CPU. such as the p lant designation. location desi g natiOll, aIld order number. Dia g n osti cs hu ffer You see the contents u f the d iagnosti cs huffe r on this page. Sel e ct the number of diagnostics

23.5.2 Reading !lut We b infor mation


To d ial ~h e CPU in the Web brow,,,,", enter th e l P a d dress ufthe CPU in the "Addrc<s" fldd in the fonn hllp:llaaa ,bbb.ccc.ddd. You can find

23 .S Web Ser.,..,
buffer "'lItries per display interval. Detailed in formalion about the selected event is di splayed. You can select the display languagc in the lOp right window. Jf the selected language is not configured, the in formation is displayed in hexadec imal code.
Mc~sage.

Variable sta tu s You can monitor the status of up to 50 variables on this page. Wh ..'lI you specify the address of the variables and the display formal, you rCc~ivo the value of the variable _ You can select the di splay language in the window "1 the top right. When specifying addresses, please note that the mnem011ic, for English (eg. I for input) differs from tho"" "fother Ian guage. (E for Eing ang"' in German, for example). S)1Itax error, arc indicated in red. Variable tables The Web server allow, you to monitor up to SO variable tables with up to 200 variable, each. fhe memory space avai lable in the CPU might not Ix sufficient to make use of all the possibil ities . If variahle tables are displayed incomplete. reduce the memory required by the mes sages and symbol comments, if pmisible, use only one language, and keep the number of variables per ts.ble low. Select onc of the configured variable tables for display. f irst. you must prepare the variable tao ble for use by the Webser"er. If you select EDtT ~ OBJECT PROPERTIES whL'lI a ,'ariablc table is .elected, Or if you create a Dew variable table, the Properties window operu;. Emer VAJiolVEB as the family "n the '"~neral- Part 2"' tab, or alternatively, activate the Web seITer'" checkbox.

Messages are displayed in chronological order, including the date and time . You cannot ac knowledge the messlges via the Web browser. You caD search for specific information with filter selling'. With sort functions. you can sort the me age., according 10 message number or ,tatu._ Detailed information about the ,elected message is displayed. You can ,elect the display language in the top right window. If the selected language is not configured. the information is displayed in hexadedmal code . PROFINE:T interface Infonnation on tile PROFINET interface i, fOUDd on the p;<ges "Parameters" and "Statistics"'. The YiAC address and the IP address are displayed. for ~xample, as are statistical analy,es of . em and =eived data packages.

'"'

Appendix

Appendix

This section ofthe book contain, useful supplements to the LAD and FBD programming languages, an overview of the COntentS of the STEP 7 Block Libraries, and a function overview of all LAD and FBD element'; ,
t>

You can also provide bloch with LADIFBD program w ith block p r otec tion. For lhis PUfl'O,e, you use the sour~e -oriented Editor in the STL programming language. You can use a funher function ofSTL. indIrect add r essin g. to transfer data arcas in the LAD and FB D programming languages; the addresses of these dala areas arc then nOI calculated until runtime. The "LAD Book'" and " FRD_ Book" libraries which you call download from the publisher's Wcbsite (see page 8) each contain a "Sample Message Framc" showing how to sel up and transfer data areas. The standard ST EP 7 package in cludes block libra r ies with loadabk functions and function blocks and with block headet> and inwrfacc descripti ons for sys tem blocks (SFCs and SFBs). A function o" crview of all LAD and FBD functions completes the book.

The "LAD Book'" and "FBD BOOK" libraries each contain eight programs which are essentially illustrative examples of LAD al1d FBD representations , Two extens ive cxamples show the programming of functions, func tion blocks and local in,tances (Conveyor Example) and the handling of data (Message Frame Exampl~). The m~mory requi~ments a~ approximately 2 MB. To try Out an example. set up a project that cor_ re'ponds to your hardware configuration an d copy the program, including the ,ymbol table, from the hbrary to the project. Now you can test the example online.

t>

t>

t>

S u pplem ents 10 G ra phic Programmin g Block Protection; IndireCI Adcires.ing ; Message Frame Example Bl uck L ib r a ri es Organi~at ;on Blocks, System Funct ion Blocks, rEC Function Blocks. 5 5-S7 Converting Blocks, TI-S7 Converting Blocks, PID Control Blocks, Communication Blocks

You can download the archive libraries " LAD_ Book" and "FRO_Book" from the publishcr's Website (sox page 8), You retrieve these librar. ies under the SIMATIC Manager w ith FILE --+ RETRIEVE. Select the archive from the dialog iield displayed. You define the destination directo ry in the next dialog field. In general, libraries are located under ... \ STEP7\5 7LIBS; but you can choose any other directory, fo1' exa mple ...\$TEP71S7PROJ, which nomlaUy com ains the projects

26

LAD Fu nc ti o n O ""'r vie w All LAD funclions F B D Function O \"c lO'icw All FBD func tions

2~

Supplements to Gnphie

l'T<l~mmini

24 Supplements to Graphic Programming

24. 1 B lock Protection


The kCYI',ord KNOW_HOW_PROTECT represents block pro:c<..1ion. Youeannot view, print Or moditY I block with this attribule. The Editor only di'plays the block header and the ~Iara tion table with the block paramet=<. In w~e oriemed input, you can protect any block. yourlClf ,,ilh K..'<OW_HOW]ROTECT. This means thalnoQne , including yourself, can view the compiled block (keep the SOurc. file in _ sa fe plilCe!). You can enter the KNOW_HOW _PROTECT block protection with STL, and it must ~ so urceoriented. To do so, proceed &ii follows,
I)

Blocks container; select the block(s) from wh:cb you want to create a source file. Cunfirm wilh '-OK".

4)

Open the source file (for example by 00...ble-<.:Iicking on the source file symbol in the SIMATIC Manalleror ~ith the Edilor and Fu.E -+ OPE-'1). You now see the ASCIl source of you. lA DIFB O block. If you have ~usly KlectW $evenl block~. these blocks will be LImInlled in order in the source file.

The entries for a code block arc in the following order:


~

the block under LAO or FBO in the usual " ay. Later. this block "ill M overwritten in the Il'ler program 810d:s by tl>l: block with the k.eyword. If you "'lIlIt to rclain the (original) blod: (strongly TeeO1nmended wben entering block protection), you CIIIl lIore the block. in, for example. P (LLieT--<:reated) library before en tmng the key"mrd. You can also store your emiR us..r program in this way.
C~a te

Keyword for the block type (FUNCflON. FUNCTION_B LOCK,ORQA NIZAT ION_ BLOCK) with specification of lhe addf"CSl\. Thi~ may be followed by the block tit le (startin& ~ith TITLE..... ) and the block comment (starting with II... ). Block. attribute>; (dcpendillg on whether you have filled in fidds in the I'roperlics pale fOT the block and, if so, how n:llmy). Variable declaration (seventl sections with tht keywords VAR_ult ..... E:-<D_VAR): depending on whether you h.ave dc<.:lared block-local variabks and, if so. which ones.

I>

I>

2)

Create a SOurce container. If then: is no object Sm",:es under the S7 program (on thc same level as the u, er program Blocki). you must create on e: Sele<:t the S7 prog"u" and mert the object SOI"-CU with lNSF.RT -+ S 7 SOFTWARE -+ SOURCE FOLDER.
Generale an STL SOUrce from the block. Cbangc 10 the EdiloT (via the task.tw, for t"umple, 0' open any block in Blocks Il!ld thl'11 close il again) and .el~t the menu item FILE -+ GE~ERATE SOuRcE. In the dialog form displayed, .," your projel:\. lCle<.:1 the object Sources. and aSiign a name for the wurce file under Object Name . Confinn with OK". The next dIalog form snows you all block. in the

c>

Projram. starts with BEGIN .nd end! with the keyword for Ihe end of the block (for cxampk ENDJU NCTTON_BLOCK).

The entries fClT a data block. are in the followUlg

order:
I>

3)

Keyword fOJ the block type (OATA_ GlOCK) ",th specification of the addrcss. Block attributes (depc-nding on w!>ether you hale filled in fields in the Propenits ~le for the block and, if so, ho", many). declaration (>1arting with STRUCT II11d ending with END_STRUCT) or, in the ca8e of instance data block!;, \~c i>dd~~! of the a~S(}l: iated function block.
V~riable

I>

:>

."

24 Supplement. to Graphic Programming

Do

Variable initialization, sraning w ith HEG TN and emling with END_DATA _BLOC K. You ente r the ke}Word KJ'\JOW J IO W_ PROTECT in the source lile, in ib own Jin~ in ea~h case, following the block at tributes and befor~ the variable declmation. If you have c,..,ated a source from several blocks, enter the keywords III all selected blocks. Finally, Slorc the SOurce file. Compile the souree fIle w ith FII.I' --'> COMPILE. The compiler create, H block with the specified blo~k anributes (i n the creation langu age STL in the case of code blocks: the creation language 1S not signilicant hcre .ince KNOW HOW PROTECT means the block Can no longer be viewed or printed out). The compiled (n~w) block is in user program B /nch and replaces the (old) block with the same number.

t>

Area pointers; these are 32 bits long and contain a sp<.-<:ific operand o r its address DB poinlCrs~ these are 48 hits lon g and in addition to the area pointer they also contain the nnmber of th~ J ata block ANY poimers; these arc 80 bits long and, in addition to th e DB pomte r, they contain further informat IOn such as the data type of the operaud

5)

Do

Do

6)

24.2.2 A rca Pointer


The area pointer contains the operand addres . and. if a pp li cable, thc op<:rand a rCH. Without operand area, it is an area-imernal pointer; if the pointer also cont ains an operand arca, it is rcf~"1T~d to as an area-crossing pointer, The notmion for constant rcpr",cntation follows: PIIy.J< P"'Zy,,, for an ar ea -internal pointer e ,g. Pl"22.0 for an a rea-cros,ing pointer e,g. P# M22.0
IS

as

Vou can set the program editor using OPTTO:---: S


--'> CUSTOMIZE on the "Source, tab so that it

automatically generates a ,ource whcn sa,-jng a block. You can use the "Run hutton w g~'lleral<: new sources from eJ<isting b locks.

where" - bit address. y = hyte address and Z ~ area. You sp<:c ify the operand ID as tbe area . The contents of hit J I different iates the two pointer types. Figun: 24.1 shows HIl pointer type s and their cOn!~nts 'IS provided by STEP 7. The area pointer has, in principle, a bit addn:ss thaI must always be sp<:cificd even with d igitHI operands; in Ihe ca,c of digital operands. specify 0 as th~ bit address. Example: Yoo can U,e area pointer P# M22.0 to addres1 m~mory bit M 22.0. but also mcmory byte MB 22, memory word l'vf\V 22 Or mcmory doubleword M D 22,

24,2 Indirect Addressing


With the programming language STL. you have a method o f acc e,slng operands whose add r~sses arc not calculated unt il runtime. This is also possible to a limited degree in LAD or FBI): Yon can wait until runtime to define which data areas yon want to copy with SFC 20 flLKMOV. However, first som e useful informatiOIl on
point~rs.

24.2.3 DB Pninter
In addit ion to the area po inter, a DB pointer al,o contain, " d ata hlock number in the form of a positi,-e TNT number. [( specifie s the data block if the area pointer points to the global data ()r ins tance <lala area. In all other cases, the lirst t,"o bytes contain zero. The notation of the pointer is familiar to you from full addres>ing ()f data operand,. llere also. the d~ta hlock and the data operand are

24.2.1 P ohuers: General Remark.l


For indirect addressing. you require a data format that contains the bit address as "ell as the byte address and , if appli~able , th~ operand area. Thi s data fonnat is a pointer. A pointer is also used to point 10 an operand. The re arc
thre~

types o[pointers:

242 Indirect Addm,ing

Aru4nlerruol poI_

, , , o

0 0 0 , , , , , , , , , , ,, , , , , , , , , , , , , ,
0 0"
~,

0"

8yte acl<!res.s

8illOdd''''''!

A,,, ,c.ol.lng point..

,,,0 0 ,,, 0
00

"""",.-

0 0

eMl

o,

, ,,,,,,,,,,,,,,,, , ,
8 8 n+2
0"

8yte acldfes!l

S~8CSd...

fo, dillo typu


Byte n By\e n+l Byte .. ~2 DB pointe, Byte n Byts n+l SytII n"2 8)'11 .. +3 B)'II n+4 8yte
n ~3

ANY point"

ANY polnll. 1S-10


Type

ANY point lS-10

101' lImerslcounte.. 101' bIocQ

lS-10

r
f-

""
Ouantity -

ff-

Ouantity -

f-

""
OUlntity -

Dala block

8yte nH Byte n+5 Byte .. of!

!-

number -

""0 """

num!l8r -

16#0000 -

f- 16)000 f-

I-- '"" -

1-- ..... I--

Byte .. +7 Byte .. +8 Byte .. *9

I--

r- .... r_ potnter

'''. ,""'"
1--- -

161JOOOO -

Byle ... ~

1----

Add,." , a:

Type In thl ANY polnllr:


El ementary dati typ. .

0 0 0 0

0 0

, , , ,

0 0

, , 0, ,
0

,, ,,
0 0

Perlphtl ral UO (P) Inputl (I) Outputl (0) Memory bits (M) Glob, 1d e ... (OBX ) Inallonee deta (DIX) 'J Temporary local cata (Ll Temporary local data J) ofilia prM""" ........ b1od< (V)

' ) NoIwIlto ~_ .. soI/Ig 2)0nIy wIlto _ ... _ .....-

" C"'" " " '" ' '' " 0'''' '" " ,'-""" " mo
BOOL
DATE

.m

Campi.. dall ty pe. OE DT 13 STR ING Par,mat type. 17 BLOCK_FB 18 BLOCKJ'C 19 BlOCK_DB

WORD

OWOR'

~~ ~~~fE~8
10 TIMER

OA

"

OC

TIM: $5TIM E

Zero pointer
00 NIL

FI~u",

14.1 Stru<:tI.On: of the Pointers in STEP 7

'"

24 Supplement< to Graphic Programming

spec iflCd, "epam ted by a p<:!riod. P#D ataBlock. DataOperand Example: I'#DB IO.DBX 20.5 You can apply Ihis poimer to a block paramet~r o f parameter type POINTER in order to point to a data Op<:!rand. The Editor uscs lIlis pointer typc inkmally to transfer actual paramet ~rs. 24. 2.4 A:\fY Poio t er

Examples:
'>

P"DB I I.DFlX 30.0 INT 12 A.rea with 12 words III DB II beginni ng DBB30 Area w ith 8 bytes beginning MB 16

> P"M 16.0 BYTE 8


I>

PilE 18.0 WORD 1 luput word IW 18


1'# .1:: 1.0 BOOL 1

I>

In addition to the DB pointer. the ANY pointer also contains the data type and a repetitIOn factor. This makes it possible to point to a data mea The ANY pointer is available in Iwo variants . For variablcs witb data types and for variables with parameter types. If you point to a ,a riahle with a daw typ". the ANY pointer conta ins a DB pointer, the typ", and a rep etition factor. If the ANY pointer points to a var iable witb a paramete r type, it contains only th~ numbt.r instead of the D B pointer in addition to the type. In the case of a timer or counter function. Ihe type is repeated in b yte (n+6); byte (n+ 7) contains BII 161100. In all o ther ca.ses, thes~ two bytes contain the value WIl16#Q000 . The first byte of the ANY pointer contain, Ihe syntax lD; in STEP 7 it is always JOhn. The type specifics lIle dat~ type uf lIle variables for which th e ANY pointer appli~> . Variables of elemcnlary data type. DT and SlRll\' G rece ive the type shown in Figure 24. 1 and the quantity I.
If you apply a variahle of data typ~ ARK"Y or STRUCT (also UD T) at an ANY param~ter.lIle Editor gen~rates an ANY poin ter to the field o r the structure. This ANY pointer contairu the ID for BYTE (021,~,J as lIle type, and the byte length o f the variable as the quantity. n,e data typc o f the individuul field or structure eotnponl.-"Uts is not sign ificant here . Thos, an ANY po int~"T points with double the number of byws to a WORD field. Exception: A point~r to B fi eld comisting of component' of data type CHA R is al ~o created w it h C I JA R type (03h~x).

lupu t I 1.0 In the C38e of paramet~r type., you write the pointer as follow>: L#Nmn bcr Type Qllantity
Exampl~s:
~

L#lO TIMER 1 Timer function T JO Li'2 COUNTER 1 Cowlter funct ion C 2

The Editor th~'ll applie., an ANY pointer that agrees iu type and quanti ty with lIle specifications in t he co nstant repres~ntation. Please nole that th ~ operand address in the Al\'Y poimer must al.o be a bit address for data typ~s . Specification ofa constant A?\'Y poinK"T makes sense if you want to access a data ar~a for which you han, not decl are d any variables. In princi ple, you can also apply variables or operand, at all A,,Y pararnCt~'!. For eXJm p1e, th e rt:presentation P# I 1.0 BOOL I is identical wi th "r 1.0 or th~ corr~ ,pon ding symbolic address. IfYOll do not specify any o.!cfaults when dcclaring an ANY paramc t"r at a function hlock. the "Editor aS8igns l0h<:x to the syntax II> and OOh<x to the remainin g byte.,. The Editor then r~prc , em, this (empty) ANY pointer (in the data yiew) a. follows: P#PO .O VOl D 0. 24.2.5 "Variahle" AJ.'lY Pointer \Vhen copying .... i th S}' C 20, you specify in the SoUTCC and destination pam meters either an abso lute-addr~ssed area (for ex am ple, P#DB 127.DBXO.0 BYTE 3 2) or a vari able. Tn botb cascs, th~ source area and th~ destina\ion ar~a are In.ed during progmrrml ing (variable indexing is nO! possible ~ven for array compo ne n(8). T he following method i, availahle for runtime modification o f a data a rca ~r~alCd al a block p'mtmet~r of type fu"\,JY:

You can a pply 3n ANY pointer al a block parameter of parameter typ~ At'lY if you want to point to a variable or an operand area . Th~ eonsmnt represe ntation for Jata types ;s a, follows : P #[DataBl oc k.]Opemnd Type Quantity

24.3
You C~~l~' variable of data Iype A)\."'Y in I~ temporary local data and usc this 10 initialize an ANY pMIIImeter. The Program EdilOrihen doe~ not generale &n ANY poinler (as it would if you trt"aled 8 different variable). but use;; lhe A~"'Y var iable in the tempomry local data as an AI\'Y pointer to a jOU!"l:e or destination ~rea. The ANY variable ;1\ the temporary local data is s!nlcrured in the same way as an A"IY point;;r~ you can now modifY the individual entries at nlnlime. This pro<:cduu functions!lOl only in the case of SFC 20 SLKMOV but also willi block parameten oflYP'-' ANY in other block!!. The "LAV_BOOK" and --FBD_Book" libraries which you can download from the publisher's Website (IC<; page II), e~eh contain a --Messase Frame E~amp\e" program, which in turn both contain an e:<ampk of the "variable" ANY poimer.

Blwf~ptiOD.ofthe

"M ......!:" FnI.ITIC:

E.umpl~'

l\I~nal:'

frame dAta

The eump1e sbows how you can define frequently occr.ming data. "mClUres IS yOllr own dala type ,nd how you use Ihis datH 1)'1)<l "'ben declaring variab les a.od parameten. We construe! II data ~!or<: for incominll and outgoini me,s~gc frames: A Send m~ilbo~ wilh Ihe llnltlUre of a mc>sage frame. " Rece;ve mailbo~ with Ihe S>IIIIe $lnlClUrt". ~nd a (~~ei'e) ring buff~r Ihat i~ to provide inlc-rmediute 'I()ralle for incoming message fr8me~. Since the data struclUJe of the message thune occun [requmdy. "'"C will define il as II user dcfinro data 1)"1'" (UDT) frame. The nru:IU# jram.. contai1l'l a frame header whose ~tnK."\UI\! we alsu ,..ant to~"C 3 name: 10. "The Send mailbox !IDd the R~h'e mailbox are 10 be data blor.:b that each eOl'tain a ~-ariable ,,~th the StnlCtUl"e of the from ... Finally. there is 31so II ring buffer. II da13 block with an array 1."<lIlS;';ting of eighl camp<>nems 1M! also ha~e the same d<ila structure "'" thr;

frame.

24.3 Drlef Description of the ,;MesSilge Frame Example"


This ~umple deals primarily wilh 1>0\1.' data is hlmdlcd, .nd IS broken down as follo".,:
I>

Tlm .... of_da~ ch eck The c~ample sho ..... s how to handle s)'st~ and standard hlocks (e"aluating etTOl'S. copying from lhe library. renaming). The timc-of--d.ay chn:k function U 10 output the nme-of-day in Ihe integral CPU re~I_lime cluck as a fi.w.~lion ,alue. Forlhis~, we requiu the system function SFC I READ_eLK. ",hieh rt"ads the dale and Ihe time-of-day from the rt"al'lin>~ dock in Ille DATb_A)o.,' D_TIMf. or oT data fonnal. Since we only want to reoo the time-of-day. w. also rt"quire the IEC function Fe H Dr TOO . This funClion felches the limeofday in-the TIME_OF_DAY or TOI) formal Imm the DT dala fonnat.
Error e>..,/ualion

Messa~'C frame data. sbm,", bow 10 bll!ldle data SlructUl"C$

I>

Time-oC--d.ay check. shows how to handle system blocks omd .nmdard bloch
Editina Ihe m~ssagc ihlme, .,ho~ the use of SFC 20 BLKMOV wilh fLxed addresses Indirect L"Opyina o f the dala area. shows an "indirect copy" function using "variable" ANY poinl~-rs
Sav~

I>

!>

I>

message fram~, shows Iheuse of~indl

~rop)'mi'

Figure 24.2 $1>0\1.... the program and dala structure for Ihl' example.

You can find Ihis program und~ "MesSll~'e f'rumc E~nmplc" in the libraries LAD_.I:look and HID 1300K which you can download from the publisher's Website (s~ page 8).

1bc ~ySI~m functioDli signal an error via binary resuh parameter tJR II!Id v,a function value RJ:.. VAL An error oeeu...-ed if binllt)' result 13R :"0'; Ihe function value is then ,ItO nega""e (bit 15 is ~). The IEC ,tandard functions signal all error only via the bmary rt"!;ull. Bolh types of ~rror evaluation an: shown in the example. If an error was encountered. an invalid ~alue is output for the time-of-day. In nddilion, th~ binary result i. a ffected. Aner the

'"

24 Supplements to GIaphic Progranuninll

DB" MeaSUllld values


Valuoel(1 .. 4J V8IuII92[1,,4J Va lulIs3[1,.41 Va lulI&4[1,41
----_~

0861

Send ms_b

ldentinll'

Numbo'

0.101

08"

Flee: malib ldentift.... Number

DB"

"""

Figure 24.2
f)at~

F"C S2
CopyOata

Str\>Cture for the Me,,,,!!" Frame OAt.

E~aml'le

time-o(-day check function has bet:n called. you ClIO Iben;forc also U~ the binary resull 10 see ifan error ha~ occurred.
Offline programming of system fimctiollS

Adore ~ving the input hlock. sy,tem function Sf C 1 and sU\ndard f unc tion .Fe 8 must be included in the amine user progTam. 80th fun~ t;ons are included in the STEP 7 standard pack3i1e. YOI.l will find these fl.lnctions in the block hbrnrie5 provided. (for the system functiuns intearated into the CPU. the library cuntmns only an interface description, DOt the actual 5~ tern functions program. TIle function can be called offiil"lO ,-is litis interface de-scriptiOll; tbe imerface de5Cription i~ n01 transf~-rred 10 the CPU. Loadable function-; such as the lEe funclions are available in the library as exa:utable
program~.)

will fmd all interface descTiption~ for the ~Y" tern functiollS.lfyou ~till have Ihe project win . dow or your projec.t opc-n, you CUll displHY Ihe two windows .ide_by_.;,",c with Wt~IlOW -+ AII.R........ uE -+ VtRTICAl..LY and drag" the selected ~y$lem functions 10 10 yuur program usinr; the mOuse (sele<:t Ihe SFC with the mouse. h old the "'OliSt key down. drag to Blocks or into ilS open window. and drop). Copy standard fu nction FC 8 in the sume way. You "ill find it on the lEe Fmlclion Blocks library. Fe 8 ;5 II loadablt function; it therefore reserves user memory. in contrast to SFC I.
If a standard function block is called under "Libraries in thc Program Flcrnent Catalog u$ing the Editor. it i. aUlomlllically copied into Blocks lind entered in the Symbol Table.

Renamj"K .uondorrifimcrions
You can rename a loadablc .tandard function. St"'kclth" standard functi"n (for example Fe 8) in the proj""t "indow and dick onc~ (aga in) on

Select the Stondarri Library with FII..F -+ OPEN under the SIMATlC Manager and op<..'11 thc SysWm 1""'lcl/rm l1/ock.< lihrary. Under Blocks, you

24.3 Brief ~scrip!ion of the "M"",agc frame Examp le"

the dc~ ; gna!or. The name appears in a frame and you can spe<:ify a new addr~,s (for example, FC 9~). lfyou p!\:ss the F\ key ",h ile ~h c ~tandard function (n.:namcd to Fe 98) is s1ili ,clc<:\ed. you w ill nc-'cnhclcss recdve the online help for the origin"! standard function (FC 8).

If an ident ically addressed block c:fists when copyi"!!, a dialog box appear,; wh~,c yo" can choo,e bet'W'een uverwriting and remuning.

In the sub,equcnt networks, you will sec a method of copying selec led variable.' at runtime with the syslem function SFC 20 BLKMOV and w ithout u,ing indirect addre~';ng. It i~ therefore also not necessary 10 know the absolute address or the structurc of the variabl~s. The principle i~ extremely simple: The desired ""py funet ;on is selected using com pari"'n functions. The numbers I to 4 arc petmis,ihle as seleclion criteria ,
FB Generul,,_ Fram c ;" programmed in sucb a way that it is ~allc d via a signal edge to generate a message framc.

Symho/ic

add",,'~

You. can assign name8 to the system function' and the 'lanciarJ functions in the Symbol Table so that yu u can al"" a<;ce" th~s~ fun~ti()m 'ymOOlically. You can assign these names freely within the pennissible limits arplicable to block name>, Tn the example. the block name in each case is . elected as a symbolic name (for
~rter id~n\ification).

Indir ect cuPling of a data

ar~a

The c~ampk ,hows the editing and u"" of a 'variable" A NY pointer w ith graphical progmm elements. lbe wpyData function cap ie, a data a rea whose address and length you can set a, required via b lock parameters . The individua.l block parameters corrcspond 10 the individ""l elements or an ANY pointer (see Chapter 24 .2.4. "AI\'Y Pointer'). The specifications in the block paramcters must bevalid values; they arc not eh~cked (SFC 20 BLKMOV signal, a copy error in its function value parameter. wbich is lransferred to the CapyDala fnnction', function value parameter), Essential elem~ 'DlS are the two temporary variables SoPain/,'r and DesPainl"r, which are af daw-Iype ANY. Thq contain th e ANY pointers far Ihe ,ystem function SFC 20 TlLKMOV. SoPo;nkt points to the .ource arca of the data to be transferred and De,<raimer points 10 the destination area. Figu'" 24.3 shows the strueNrc of the S"Pvinla variable; DesI'aimer has the same SlrucNre. The individual bytes, words and doublewords of the ANY variabl es are acce>scd via their ah.wlute nddre>ses ,

Editing the IDI'<UIlC frame

The data block S~nd Mail!> L. to ~ filled with the dam for a message frame. We use a function hlock that has the ID and the con,ecutive num~r stored in its insmnce dam hlock The net data are .tored finally in a glohal data hlock; they are copied into the Send mai lbox with syslem fun~liQ!l fjLKMOV We u~c th~ limc-orday check funelion 10 take lhe lime-of-<lay from the CPU's real-time d ock .
lhe [!CSt nCMmk in the function block fB Generalc_Ftame transfers the 10 stmOO in the instance data. h lock to the frame h eader. The consecutivc number i. incremented by I I and is also tnlIl,[cmd to the frame h eader.

The >econd network conmins the READ_eLK fun~tion call that mkes the lime-ot~day tro m the real_lime clock and emers it in Ihe frame header in nME_ OF_DAY fonnaL

Byte 0
~

Byte t

woro ,
SoNu m

Ward 4

Area Pointer

16#10
F i~D""

SoType
Sln!L~UTC

"'0'

!1

"""

24.3

of Ihe Variable S"Painla

..

I
SoByte

.~

SoBlt

413

24 Supplements to Graph ic Programming SAve message frame The example shows the use of the CopyDalo function (copying a dala area with programma~ ble address),
A message frame in the data block Rec~Mai!b i. to be wrinen to the next location in dam block Buffer. The block-local variable Entry deter-

The ,,/'y variable has a value range of from 0 to 7. In the first network. a comparator determines whether EntlJ' ;ii less than 7. If this is the case, Entry;s incremented by 1 in the next network. otherwise it is set to Zero. EntlJ' multiplied by 16 gives the absolute byte address of the next enlry in the ring buffer (the data structure Afessageframe consists of 16 bytes). The CopyDala function, which copies the mes_ sage frame from the Recei,c mailbox (data block DB 62) to the ring buffer (data block D8 63). is ca lled in Network 3.

mines the location in the ring buffer; th~ value of this location is used to calculate the address io the ring buffer.

'"

25 Block Libraries

2S Block Libraries

The STEP 7 Basic software includes the Stan dard Lihrary which contain, the following library programs:

25.1 Organization Blocks


(Prio - o.-fauh priority class)

, , , , , , , ,

Organization Blocks System Function Blocks IEC Function Blocks 5557 Converting Blocks TJS7 Convening Blocks PID Control Block. Communication Blocks Communication funclion. Miscellaneou. Blocks Time syncbroni2ation and slamping

00 Pri o Designation
I
Main program Timc-{)f day interrupt 0 Time-{)f day interrupt 1 Time.of.day interrupt 2 Timeofday interrupt 3 Timc-{)f.day interrupt 4 Time-{)f.day interrupt S Time-{)fday int~rrupt 6 Time--of day interrupt 7

10 2
II

12 2 13 2 13 2 2 16 2

"

OB Prio Designation
20

f urther supplied libraries are STMAT1C_ NET_Cr, wb ich contai ns I ~ communications blocks for the CP module. in the library pro gram, CP 300 and CP 400, Redundant 10 (VI) with blocks for module redun<lancy, and R~dundant 10 CGP witb bloch for the redun dancy ofindividual module channel . You can copy blocks or interface dcscriptions into own projects from thc library prograIm descrilx><l.

21 22 23

3 3 5 6

Time. delay Time delay Timedelay Tim edelay

interrupt 0 interrupt I intcrrupt 2 interrupt 3

30 7 31 8 32 9 33 iO

" " 35 36 37
3S 40 31
32

Watc hdog Watchdog Watchdog Watchdog II Walchdog Watchdog II Watchdog Watchdog 15 Watchdog

"

interrupt 0 (5 s) in terrupt 1 (2 s) interrupt 2 (I s) interrupt 3 (500 ms) interrupt 4 (200 ms) interrupt 5 (1 00 ms) inteITllpt 6 (50 ms) interrupt 7 (20 ms) interrupt 8 ( I 0 fiS) interrupt 0 in terrupt I interrupt 2 interrupt 3 interrupt 4 interrupt 5 interrupt 6 interrupt 7

33

" 46 "
47
55 56

16 17 18 19 20

"
2

Hardware Hardware Hardware Hardware Hardware Hardware 22 Hardwa,.., 23 Hardware

2
2

57 W

DPY I status interrupt DPYI update intcnupt DPY ! vendor interrupt

25 IV!u!t;processor interrupt

25 Block

Librarie~

DB l"rio De~ignation
6i
62 63

IEC rimers a nd LEC

~ounl c n

" " '" " " " " " " '" " "
70
72 73

SynchronoUll cycle interrupt 0 SynchronoUll cycle interrupt I Synchronous cycle interrupt 1 2S Synchronous cycle interrupt 3 Technology syn chronous interrupt
1/0 redundancy error C PU redundancy eITOr Communic ation redundancy error

SFB Name

Osignation Up counler ()Qwn counter Upldown counter Pul se On dclay


Offdc!~y

, , ,
1
3

CTU CTO
C T UD TP
TON TOF

8J
8S

'" 26 26 " " 88 " 29


87
~,

26 Time error l) 26 Power supply fault I) 26 D iagnostics interrupt' ) 26 Inse rtlremo'"e-modulc interrupt \) 26 CPU hardware fault IJ
Priority class error I) O P error n Communications eITor Pm<:essing abort

S7 t ommunkat\on

SFB N ame 8 9
USEND lJRVC l:JSE:"O BRCV
GET

Designation Uncoordinated Rnd Uncoordinated receive B loc k-orienled $C'nd Block-oriented receive Read dala from panner Write data \0 panner Write data \0 printer Tn il i"te cold or wann stan in the purtner Set panncT to STOP Initiate restart io Ihe purtner C heck status of partner Rccei," status of partner c Osignation Check communications stut us Determine connection
statu s

"
13
I)

Background processing

W,um reslart 10 1 27 Hot ,""start 102 27 Cold restan


100 27

" " " 19


20

PUT
PRINT START STOP RESUME STATeS USTATUS

21

12 1
I)

12l Prio -

Proaramm ina error 110 access error


28 III ",~ .. n

"

23

SfC Name

25_2 System Function Blocks


CPU clock and run _time meter SFC Name
0

62
87

CONTROL

C_ D IAG

Desi gllatioll

,
"
3

SET_C I. K Set clock READ_eLK Read clock S ET_ RTM CTRL_ RTM REA D_ RTM SNC_RTCB TIM EJC K S ET_eLKS RTM Set run-time meter Modify run-time meier Rcad run-time meter Synchronize ~lave clocks Read syslem lime SCI t ime and clock status Usc roll_time meter

S7 basic communlcMtlnn
SFC ","ame

Dcsignation Send dllia eXlemally Receive data e}!:temally Read dala externally write data el<temally Abon e:l ltema) connection Read data intemaUy Wrile data illlemally Abort imernal connection

65
66

X SND
X _ RCV

" 100
101

67 68 69
72

X_GET X_ PUT X ABORT


I G I::' T

73
74

I PUT
I_ ABORT

."

25 .2

Syst~'1n

Function Bloch

Global data communicati ons S}'C l\'amc 60


61

Drum SFS Name


32

Designation Send GD packet Receive GD packet

Designat ion
Drum

GD SND OD_RCV

DRUM

S7_3i10C polnt-to-poi nt coup li ng SFB Name Designation

II -CPU SFC :\ame 90 H CTRL Designation Control opcnlting mode, onH -CPU

6<J

SEND l'TP

"
62

Send data (ASCn, 3964 (R)) Receive data RCV]!'P (ASCn, 3964(R)) RES RCVS lRlctt receive buffer (ASel!, 3964(R)) Send data (RK 512) Fetch data (RK 512) Receive and provide data(RK512)
fu nction~

Interrupt ove nts SFC Name Designation Sct tim~-of-day intemJpt Cancel time,of-day imemJpt Activate time-of-day mterrupt Query !ime-of-day mterropt Start time-delay interrupl Cancel lime-delay interrupt Query lime-delay interrupt Trigger mul!ipnx:eSSClr alarm

63
M 61

SEND RK fETCH]K SERVE_RK

28
29
30

SET_TI::-" CANJINT ACT_TIi\"T QRY _ TTi\"T SRT DINT CAN DINT QRV_ DD.'

Integral S7-JilOC SFB Name

Designation Position ing with analog output Pm;itioning wilh d igital OUIPUI

"
n
D

"
" 48
49

"

ANA LOG DIGITAL

34
35 30

Control counter COUl\L FREQUENC Control frtquen~y


mcasu r~m~nt

MP_AL""

PULSE

Cumrul puls.e-width mod ulatiou

"

Mask synchronous erron; MSK FLT OMSK FLT Unmask 'ynchronous


READ ERR

Integra ted functiom CPLi 31213141614 SFS Name


29

'"

,="event ,tatus rcgi..er Read


Disable interrupt ~ve nts Enable interrupt cvent. Delay interrupt events Enable intetnIpt events

Designatiou

30 38

39
4>

HS COUNT High-speed counter FREQ.MIS Frequeuey met<:r Control 'Counler AlB" HSC_A_S Control Positioning" 'OS CONT_C CoDlinuo us dosed-loop control Step-action control Gen~ate pulse Designation CaU "ssembler block

39 40 4> 42

DIS EN DIS EN

lRT IRT AIRT AJRT

Add ..... ss m od ules SFC Name De,ignation

"

50
70 71

GADR LOC Detennin~ logical addre LOC GADR Dctcnnine 'lot RD LGADR DClcnnine all logical addresses GEO_ LOG LOG_GEO Detennim logical address Detennine slot

SFC Name 63 AS CALL

'"

25 a lock Libraries

Dah. record trans fer


SFB Name 52 53
81

Dist rih u ted 110 SFB Name 54 75 I{ALRM SALRM Designation Receive intcrrupt Trigger interrupt

Des ignation Read data record from a DP slave Write data reeord to a DP slave Read predefined parameters Designation

RDREC WRREC
RD PAR

SFC N am e

7
11 12
13

DP PRAL DPSYNJR D ACT_DP

Initiate hardware interrupt SYNC/FREEZE Dcactivate or activate DP slave Read slave data Determine bus topo logy

SfC Name

54 55

"
57 58 59

RD DPARM Read predefined parameter WR PARM Write dynamic parameter WR DPAH2vl Write predefi ned pmameter PARM MOD Pardm~terize module WR REC Writ e data r,ord Read data record RD_REC Read predcfined parameter

DPNR-'1_ DG Read diagnostics data DPRD DAT DPWR OAT Wri te slave dm.a

14 15

103 DP TOPOL

Creat e blo ck-rel at ed m ess ages SFB Kame


D~signalioo

102 RD DPARA

P r oce .. ima ge updating SFC Name


D~,ignation

" " "

33

26

UPDAT_ PI UPDAT]O SET RSET

Update process- image input tab le

NOTifY 8P Messages without acknowledgment display A L AR-'1 Mess ages w ith acknowledgment display

ALAR.VI 8

27
79

Update process-image
output table Set 110 bit fie ld Reset ri O bit field

Messages wilhout accompanying values ALAR.v! 8P Messages w ith accompanying values

80

;0

NOTIFY AR SEN D

126 SYNC

"

Update partial process image of inputs in isochrone mode Update partial process imagc of outputs in isochrone mode

37

Messages w itholU acknowledgment display Send archive data Designation Enable mes<;agcs Disable messages

SFC Name

127 SY NC PO

9
10

EN_M SG DIS M5G

17
System di a gn os tic. SFC Name 6 51 52 RD_S1NFO RD SYSST Designation Read start information Read SYS ST Sl.Ib li sl

19

"

ALARM_ SQ Me"agcs that ~an be acknow ledged ALA R M S Messages that arc always acknowledged ALARM Dctenninc a~knowledgment status

- ,c

'"

READ

WR U SMSG Entry iu the diagnostics buffer

106 DEL 51

"

Read dyn amic system resources Enable dynami~ sys1.Cm resourCes

25., IF:C Function Block'

'"'
<0"

ALARlI.-CDQ Me"age, that can be acknowledged ALARM 0 Me"ages thaI ~re ajv,(ays acknowl edged

25.3 lEe Function Blocks


String functions
Fe

Name
LEN LEFT RTGHT MID

De, ignation Length of a STRING Let] section ora STRING Right s~~tion ofa STRING Middle section of a STRTNG Concatenate STRINGs Insert STRINC, Odele STRING Rep lace STRING Find STRING Convert TNT to STRING Convert DINT to STRING Convert REA L to STRJNG Conwrl S'I1tlKG to TNT Convert STRNG 10 DINT Convcrt STRIKG to REAL

Co!'}' H bloek functluns ud

SFC Name

Designalion Copy data area P",-as:;ign dar" ar"a Create data block m work memory Delete data blocl:: Test data block
m~mory

" '"
2
3

" "
"
23

BLKMOV FU.L CREAr DB DEL DB TEST DB REPL VAL

32 26

.,
8'
82 83

"
25

CO:\fPRESS Compress

" "
5

Enter suhstilll1c valuu

" "

CONCAT fNSERT DELE TE REPLACE FIND I STRNG or STRNG R


SnU~G

UBLKMOV Copy data area wirno"l gap' CREA_DBL (iencrate data block in load m~'lnory READ DBL Read load memory WRIT DRL \Vrile load memory Ci{A DB Cr~a\c data hlocl:: in work memory

'"

38

STRNG_I STRNG OJ STRNG R

39

"

'"
85
3.1
30

nate and time fn nctluns

Program contro l SFC Name RE_ TRI(jR STP WAIT OB RT CiR Designation Reuigger cycl~ lim~ monllor Chang" to STOP .Itatc Wait for delay time Determine OR runtime ConfigllT"tion in RlJ).< Changing program protection

'C Name
3 6 7
D_TOD~DT

De,ignation Combine DATE and TOO to DT ExtrnCl DATE from DT Extract day-of-the-week fmmDT Extract Ton fmm DT Convert SSTIME to TIME Convert TIME to S5T1M E

01 DATE
DT DAY DT TOO SST! 'JlM TIM SS TI

" ''''
7<

,
;J

30

<09 PROTECT

.1, .13

AD DT TM Add TIME to DT SO DT T\1 Subtract TIME from DT SR_DT_DT Subtracl DT from DT

Blocks rur PROFfNET ClJA SFC Name Dc,ignation Update input. Update output< Update DP connections

Compari!(ln ~

Fe N=,
9

Designation Compare Dr for equal to Compare OT for not equal to Compare DT for greaK'I than Compare OT for g~a\er than or equal to

III PN IN

Pi': OUT

28

FQ DT :\'E DT (i'T_DT OE DT

'" PN DP

" "

2S.s TJS7 Convertin!! Blocks


Exponentinl function with ba~c e 124 ZEHN_H_'" ExponllTltial function with base 10 125 A2_H_ A 1 Exponential function with any bas<: 123 E_H_N

SO

RAD 16

16bit fixcJP<'int ~l!are root extractor

9<l 91
92

RnG SCHB Bitwise shift register REG_SCHW Wordwi:;;: ~hm rC "iS1C"T

REG FIFO
REG_ LIFO DB_COPY I DO COl'Y2 RETTN LADEN COD_ llS COD 32

OJ 94

(FIFO) Stack (LIFO) Copy data area (di"'cI) Co py data area (il\di~ct) Save scrntchpad memOl)" (S515SU) Load scratchpad m~mory (S5155U) BCDbinary conversion 8 decade! Bin3ryBCD convcrsion 8 decades

BulT~r

25.5 TI - S7 Convcrtin2 Bl o c k s

"

96

m
80 81

Name

Dcsignation

"
98

"'
83

""
Fe

"'

Ana loll functions Name


O<:~iptation

"
SO

LEAD_ LAG Lead/lug algorithm DiSCfet ~ control time DCAT intcnupt MCAT Motor control time mtenupt Index matrix comparison IMe Matrix scanner SMC Fvcnt ms!kable drum DR uM Col leet/distribll1e table PACK

Fe Name
80 TONR 81 I13LKMOV 82 83
84
RSIlT

".

Desillnation Lalching ON delay Tnmsfer data are~ ind irectly Relet process image bit by bi\ Set process image bit by bit EnltI value in tahle Output first val ue in table Find value in tahle Output last value in tQblc Execute tahle operation Copy value from the tab le SaveualUm Combine tnble c\~ment Shift b it in bit shift register
Bit pattern for 7'i~gment display A SC JI hCl'adccim ~ I conversion I ! el'adc~lmal.ASCI1 conversion Least ,ig:rificant ,et bit Sct bit in word G~ncrate len, compleme nt Count sct hits Rc~et PQ byte by byte Set I'Q bytc by byte

100 AE_460_ 1 101 All. 460_2 102 AE_463_ 1 10) AE_463_2 104 AE_464_1 105 AE_464_2 106 AE_466_1 107 AE_466_2 \ 08 RLG AA I

Analog input module 4~O Avalog input module 460 Analog inp ut module 463 Analog input module 463 Analog input module 464 Analog input module 464 Analag input module 466 Analog input module 466 Anaiag output "'Mu le Analog output module PTIOO distributed VO IIT100 dilrib uted 1/0

SET
ATT

109 RLG_AA2 110 PER ETl


III PER

83 86

FIFO
TllLJIND LlI'O TIlL TBL_ WRD

En

"'

88 89

90
MMt h functlonl

WSR
WRD_TBL SHRB

Fe
III 113 114 115

Name

Designation Sine Cosin<: T,mgcnt Cot""t:: cnt Arc ~inc Arc co~inc Are tangen! Arc cotangent Natur.llogarithm l<lgarithm to base: 10 Logarithm to any base

" 02
9l

SEO
ATH

SINUS COSIl\'US TANGENS CaTANO

116 ARCSIN 117 ARCCOS Ilg ARCTAN 110 AReCOT 120 LN_X

" "

HTA
NCO DECO BCOCPL

"" 97
98
99

121 La_X
122 B_LOO_X

DlTSUM 100 RSETI 101 SETI

" I

25 Tllock Libraries W 2 DEV Calculate standard dcvim ion C<'l!Tl;wcd data table< Table combination Scale values Un~cale values For DP staudard sl!lv~s and PROFINET 10 devices

IOJ 104 105 106

COT TEL TEL SCALE UNSCAlE

FB Name

Designati on Read in put< Sct Olllputs Read inputs consi<tently Sct OUtputs oon~i~tently

20
21

25.6 PID Control Blocks

22 2l

GETIO SETIO GETIO]A SET!O]A

'B Namc
41

Designation

IF: cmnmuniclltion s
Continuous control Step COntrol Generate pul<e Continuous temperature control Step temperature control

42
4l

"
"

CONT_C CONT_S PULSGEN TCONT_CP TCONT_S

FB Name

Designntion Send data Receive dutu Establish connection Cancel connection Send data via UDP Receive data via UD' Designation

6l 64 6S 66

25.7 Communication Blocks

67
68

TSEND TReV TCON TDISCON TUSEND TURCV

FB Name USEND URCV BSEND HW;CV GET PUT Name Dr SEND DP RIXV DP mAG DP_CTRL C CNTR

Designation Uncoordinated send Uncoordinated reeeivc Block~oriented scnd Alock-oriented recci,'c Read data from partner Writ'" dam to partner Desi!lnation Send data Receivc data Diagnost ic s Control Scan connection Status UDT Name

9 12 II 14

1S
FC

,
4

1 2

62

Data structure for connection configuration 651 TCON rAR TCP_conn_ active 652 TCON]AR TCP_conn....passive 653 TCON_ PAR ISOonTCP_,onn active 65< TCON]AR ISOonTCP_'onllJ)ass ive 6" TCON]AR ISOonTCP_conn _CP_active 656 TCON]AT ISOonTC1'_conn CP""pllssive 617 TCPN]AR UDP _local_opeJ1 66 TADDJAR Address structurc of the communication panncr UDP rem_address Hnd

"

TCON_PAR

661 TADD]AR

PO"

25_8 M'KfliaueolU Iilorks

2S,K Miscellaneous Blocks

FC

N~,

Designation Send data Re.:eive data DiBgn05tics Control

Fe
60
61

Name
LOC_ TlME BT_LT LT_ HT S_ LTlNT

Designmion Read local lime and


swnm~r

,
I

ILl

62

63

Convt'rt modult' rime into local t;nlt' Convert localtinx imo module lime Sci Lime imCTTUpt accordillillu I<>cal time Designalion Switch over SUn>mt'I'lwinter lime S .... ilCh ov",. summC1'/winlC1' lime with limt'stalUS Send lllCssagCS with time stamp Designation
Rul~ ror summcr/wint.er Iiitit' JW;lehinll

,
4

DP SEND OP_ RECV DP DIAG DP_CTRL AG_SI::."1\'D

FB
60

Name SET SW SET_SW_ S

"
62

.
8

Send daLa (rROFIBUS FDL and Industrial Elho.'1IlCl) AG_RECV Recti,'t' data (PR O FIllUS FDL and Industrial Ethernet) AGJOC K Di sable data exchange (ln dustrial Ethem~1) AG_1J?;'LOC Enable dala t'xchangc (lndustrial EthernC1)

fTP C O NN
FTP STOlt FTP RTR FTP_DELE F'TP QUIT

E..'Ilablish
~~,

~Iion

to

T1MESTMP

U DTNwne

" " " "


43

SC1'Id data block to .scroe. Send file to elicnl {klete file on 5Cl'\'C' Cancel connection Scan eonn(X:t;on status Designalion FILE_DB_ HEADER

C_CNTRL

UDTName

60

WS RULES

Llbnry prol,tl"am CP 40f)

25.9 SIMATlC_NET_C P
Llbnry p ..... gr am CP 300

F .

Name

Desil1nalion FMS communi cations: Identify partner Read dau. from partner Send vanablej R~esl statull inronnat;on from partner Write data 10 partner Send coll/lt'Clion configuration Designation Send dalll (PROFIBUS FDL and Industrial EltternC1) Rccei~e data (PROFIRUS FDL and Indu.sllia! Elttem et) Disable data excbange (Industrial Ethernet)

F.

N.~

Det; i lllU'1ion

, , ,
3
4

IDENT READ RF.PORT STATUS WRlTE USEND URCV a SEND BRCV GET

6
9

FMS communications: Identify pIIMDCT Read dat.a from panner Transmit variables Request stahl. infonnntinn from partner Write data In partner Uncoonlinated send Uncoon:linared receive nlock-arientcd 5Cftd Illock-orirntcd receive ltelKl (\ata from pIIrIner Wrill' datu to parblt'r Send config uration

, , ,
3 6

lDEl'<, READ RF.PORT STATUS


W RJTE

" FC ,
6

IP_(.'ON f

Name AG SEND

12

13

AG_RECV

"

" "

eUT
IP CONF

AG_LOCK

25 Block Libraries 8 A G UNLOC Enable data exchange (Industrial Ethernet) FTP CONN FTP STOR FTP RETR FTP DELE FTP QUIT Establish connection to server Transmit data block \0 server Transmit file to client Delete file On server Cancel connection

'"

RED DIAG 452 RED STAT

"

'" "
43 44

Diagnose redundant 110 Read status of redundant 1 0 / Designation Initialize 110 redundancy Trigger depassivation

FC Name
RED INIT 451 RED_ DEPA

'"

"

60

AG LSEND Send data (TCP connections) AD LRECV Receive data (TCP connections) Designation FILE_ DB_ HEADER

25.11 Redundant 10 CGP


S upport of redundancy for Individual module channels Library program Red_ tO

UDT Name

FB Name
450 RED IN '5 1 RED OUT
452 RED DlAG 452 RED STAT

Designation Read reduodant 110 signals Output redundant 110 signals Diagnose redundant (/0 Read status of redundam 110 Designation In itialize 110 redundancy Trigger dcpassivation

25.10 Redundant 10 (VI)


Support of redundancy for modules Library program Red_TO Designation FB Name

"I

4"

RED IN RED OUT

Read redundant 110 signals Output redundant 110 signals

FC Name

"I

450 RED INIT RED DEPA

26 Fuoction Set un

26 Function Set LAD

26.1 Bask Functions


Memory
Sin,. cuil
fun~ ti on.

Blnuy ch""'ks and comblnatlun.


NO <""toct

MldU ......up.n

NC .......

< .

r
Il.o,ot <Qil

Bi ..... 'Yoper_

'. --.-

I' 1>----1

.::;_ Slnary Operand

SR NIx

. '' ' ,

"

Timer fune!i"m

a''.

~.
MSbo.

,'
,

,.:: ;.;
~'-

,."" , " a -

"'

J n61~ld" .1 .1'IlI'llf'

S""" Iii with


I~ne

'1IY>8I" 01"1"'''''
( 81)
O\llllltior'l

mod<

/ ,

....11h'. ... gein th.po..... _

Mesa coil
NO """Ioc~

1'00111 fd lt<' ,,,f ... oPl"" ~

-1'1
II
V1
SP Pulse SE Extended Pulse
SD ON dela)'

-".....,

J
,

NC <:OIl"",t

Timer op<!f8.nd .

With the timer Cbaraclcti ,tics:

S_PULSE S_PEXT
8_0D1

-,

5_00TS S_OFFDT

55 Stored 0'< delay SF OFF delay

425

26 funct ion 5<-1 LAD

Transf"r fun"Uons
MOVE EN ENO-

26.2 Digital Fu nctions


-

Comparison functio ns

'N

ou,

=''NN''
Compare for equal ' 0 nO! equalw
than equal len 'han Ie.. 'han or equal to

Counter function.
Counter op.narK! S_CUD - CU Q~
CD

accord ""IIO

-,
~,

"'NT
- 0
~o

REA'

- R
~R

- S _
pv

cvf-

-="""' or " , areat" '0


<, <-,

>0 _ 0
<0
~O

>R _ R
~ ~R

CV_BC0rR

Count up coil

Counter operand

--{(,cui
Count .. r operallO

I I
A rhbmetk functions

Cu"'" down coil

--{('co)
Counter opetlInd

Sec ~'" coil


w;,lI~t

-{('scI

Cw",

I
" rhllmetk: b ...,

Rose't'(Iit

Counler~nd

--{(RI
Counter operand

I
Calc ulation Addition Subrr""tioo Multiplication Oivi5ion

='N' = EN IN1 ENO OUT

AD0_I

NC contact

-{IIf---accordinj to

--{(,1f---Up,ldown counter Up counter Down COIIn{C'

Counter ope rand

'NT
AOD_I SUB_ I MUL_' 01"'.'_1
~

D!NT

ADD_I)[
SUB_ OI MUI __ DI

Wilh the cOllnte r c haracteristic s:

Dlv_o r
M OD 01

REAL ADU_R SU8 R MUL_ R OIV_R


~

Moo"'"

'"

16,1 Digita l

~' unet;ons

Mathematical Functions
M.tb hox

Shift Functions

'"
Sine

ENOrOUT

Shift bOI

SHL W EN ENOl-

=,,~,---_O_ rU~T
SHL_ W SilL_OW SHR W SHR DW

SIN CO,
T~

Shift word left


Shift doublcword leU

Co , ine
Tangent Am ,inc
Art cosino Art tangen,

Sl1 iff word right


Shift doublcwOTd rigM

"'"
'OR
EXP

ACOS ATAN

;>ffi -

Sl1 iff word with sign Shift doublowOTd with ' igr<

SHR OJ ROL_ DW ROR DW

Finding the square

Rotate left
Rotate Iiiht

SQRT

Finding tho square root


F..tabli , l1 ing the exponent Finding the logari thm

u<

Convcrsiun Functions

"
CEIL FLOOR KOUND
(0

Word Logic
WAND_ W EN ENO IN' OUT

I BCD -EN ENO IN OU T

Word l<>gi< b<J~

'"'
WAND W
WOR W WXOR W

AND

"'oro

OR word Ex<iu,ive OR word

Com'CT>ion of OINT ' 0 REAL Com'c"iOD of UCD

WAND OW AND doublcword WaR_OW ORdoubleword

WXOR OW Excl usin OR d""hl""'ord

with rounding

next higher number


ne~t

(0

lower numoc--r

to next whole m,mber

TR UNC
INV OJ
DINT one '.

NEG Dl NEG R

DINT nega tion

427

26

FUD~lion

Sel LAD

26.3 Program Flow Control


Stulus Bits
Re,ult lP" "t~ r than zero

Mas ter Control Aet inte

Reb}'

MeR orea
>0
De.c\i"~t<

f--jMCRAi--l f--j(MCRD)I---1
---{MCR-<))-----i f----{MCR)-----i

"""11-1"""1 1-1<0

MCR HrCa
O~ " MCRw n e

Rc,,,ll gf'<'ater tha n


o r equ~l lo ""'" Res ult less than uro Ro:.s ult le than or equ~1 lu >e'" Rc.ult nol equal to . e m

Clo se MCRzonc

------111-1Block Functions

--jI l-l<>0

"""111-=~ O

Ca ll i" g" fun c tion block "i(h dota b loxk

Re.ult c'luHI 10 zero

-"""111--uo

Calling a s)'S!<IIl
fu nction "bl<><k wit h d au, block

Re.uH in , ..u ~ (unordered)

,
#nam "
EN ENO IN 1 OUT 1 IN2 OUT2

-"""111-OV

O v e rflow

-"""111--os

C~llinj,: " functio n

Slore ~

overflow

-"""111--BR

b l""k or a 'y>1cm fu nction b lock as loca l in stallce

Binary f8 u lt

-"""111-----iiSAV')f--!

C alling 0 fUDction

CC>

SAVE c oil

EN ENO IN 1 OUT 1 IN2 OUT2 Call ing a system funct ion

SFCx
EN ENO IN1 OUT1 IN2 OUT2

Ckllin. u

Jump Functinns
J ump if RLO "I "

non.parameterized fu nc tion

cC>

--{ CAll)f--I
SFC )(

Colling a non.param ete r i7ed system [wnctioo

--{ CALl)f--! --{ RET )f--!


DB>

Junlpi f
RLO - " 0"

D.. slina~on

---(JMPN))-----i
De s tination

RET coil, block end

c on dit i on~ l

Entry, j um p label

","> cL.t. hloc k

f---li DPN )f--j

27 Fuuction Sot FBD

27 Function Set FBD

27.1 Basic f'unctions


Momor)' FunCllon.

Binary Check< a nd Combin ation.


A.N 1I funotiDD

----1 I
-------1
1/

Bir.ary operaoo

Olt function

Bin8ry <>perand

I--

E.du,lvc-O R
fno<lioD

Binary operaoo

~ f,., ~ f'OR ~ f&

-------1 s I
Binary operafld
R...,

-------1
Bina

Ch .... for .lgn. I ..... "1"


Cb .... for d;n. 1 n<!l0tlon

--1
-4

operand

".t. "n",

Sit box

'R
R

a
RS

Timer Functions

Binary <>perand

as box
R

a
Po,it"" odge
Edge mern<>ry bit

lodlvldnal clcmeots

orlbcRJ,o Nl1Iath'c Ig.


of lb.

----l

I--

sran oox with


limo moo.

Tomer operand

:::j ", " I


T""..r ope'and
-j
R

RJ.o

Reset oox Check luner ,ran"

T""", operand----rTimer operand

--ct..-

With the timer S PU LSE S PEXT S onT S ODTS S_ OF FDT

~haracteristics:

se
se
SO SS

""'K Puis", Extended


ON delay Stored ON delay OFF de lay

se

27 Function ScI FBD

Transfer

~unctions

27.2 Digital Functions

MOVE box

MOVE EN OUT

Co mpariso n Functio n s Compa rison bH


-

'N

ENO

CMP = .. I tNl

'N'
Counter F unctions Counler box
Count ..r ope rand SCUD cu CV CD CV_ BCD

Com pare fo r eq ua l !o no! eq ual to greater than

according 10

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

<NT

"'NT

REAL

S
~

Individual clem e n ..

greater than Or equal !o less than


k than o r

- 0 = 0 >0 _ 0
<D

- R = R >R _ R <R <-,

Count up

bo~

--1 --1

Counte r operand

<-D

cu
CD

equal to

Count d own box

Cou nter operand

A rithmetic func t ion s


Ar hh m~tlc

Set connter box


w ;!b ~ou n '

Counter operand

:::j
-l

PV

SC

I
I

box

Reset box Check


coun ter Slatus

Counter operand
R

= l NT

EN
IN1 IN2 O UT ENO

f--

Counter operand Count .. , operand

----r---cL...
it"
Multiplicati o n

With the counter characteris tics:


Up/down counter Up counter Down counte r

Di vision
M odu lo

DI V ]

27.2 Digitalfnnction.

Malhemadcal
MOlb bOl

FUDctlon~

Shift Functiuns
Shlfl bo.

Si ne
Co,ine

SHL_ W

Shift wmd loft

SIlL D W
SHR W SHR DW

Shift duubl~wo<d left


Shift w ord ri ght Shill do ubloword right
Shift word with sign Shift doublew e>rd wi,h ' ign
R(}"'~

ACOS

Arc <o.ine

SIlR !

SI IR....[)I ROL OW
RUR IJW

left

ROl<l le righl

Word Logk
Con~eNion

Fu nction s
WAND_W

Connr>.ioll bOI

OU T ,"0

'"
M'ITI word

IN1 IN2

OUT ENO

,',',

~~.,

...

'DO
Conv~"ion

ofl"'T 10 BC D
WA ND

UR word

helnsi' " OR word

ow

A N D <ioubic",,,,<i

10 INT to ON!'

WOR_DW

W:XOR OW

OR doubl. word hclu.in OR douhlowmd

"
CEIL

to nexl higher numbc.,. '0 no" lowe r number tu n ex' whole number

H.ooR ROUND
TRUNC

.... EG VI

27 Function Se t FBD

27,3 Program F low Control


Status HIts
Result greater
th an zero

Block Fuoctloo s
>0 >-0 <0 <_0 <>0 --0
UO OV

I--I--I--I--I--I--I--I--I--I---

Reoul! KICatCr thlUl or e qual to zero Re<ult Ie .. tbon zero Result Ie.. than or equal to zero Re<ult not equal to zero Result e qua l to zcro Result invalid (unordered) Overflow Stored overflow

C a lling a function block w ith data bloo;k

C" llin~ ">Y",C "Ill function block "' ith da ... block

Call in G a function b lock or

a system fun~ ! io n block


~>

local instan ce

- 'N
-

- 'N'
Ca ll ing a fu nu iotl

'N' OUT2 OUTt

#n ame

'"0

0'
'R

C heck hinaty result Sav e bin ary re.u lt

- 'N
-

'C.

OUTt OUT2

-------4 SAVE I

Calling a . y ste m fu nction

'"' 'Na

'N '

Jump Function.
Jump if
RLO - " \ "

- 'N -------4

-------4

Destination
JMP

r'" 'NO rr'N'


OUTt OUT:;>

SFCx

Jump if KLO - "0"

----i JMPN I
Destination

Destination

C al ling a non p a l"ame<e!u e d fune, i<>n Callin g a non . param elO rized syS\em fu n Clion Con ditional bloo;k end

'C.
CALL SFCx CALL

I I

E ntry, jump label

---l

Master Control Kelay


Activace MCRarea

---1

Rn

"'""

MCR u mc Clo,"", MCR ,.one D<......,tivate MCR area

-------1 MCRA -------1 MCR< -------1 MCR>


-------4 MCRD

a~.

data bk>ck

a,. ---1 a'N

lnde"

Index

A
Actual parameters 257 Address priority 77 Addre.sing absolute 117 indirect 40H symbolic 11 8 AND funClioo \36
ANY pointer

programming FED 112 programm ing general 73 programming L AD 11 0

pwpenlcs

10 1

description 410 introduction 165 Arc functiom 204 Archiving proje<:ls 56 Arithmetic functions 197 status bits 222 ARRAY (data type) 126
AhcI.--rlaining a module Assign OOx (FBD) 146

protection 103, 407 structure 1()() transferring 83 types 99 Bo, a<sign bo" 146 memory box HID 148 mcmoryhox LAO 144

reset box 14g ,elba" 148

C
383

.ddr"",

AsynchmDous errors 398 A utomation License Manager

50

B
Background scanning OB 90 275 Binary fl ags 22 1 Binary logic opcmtioru; 131 FHD 134 Binary result 222 EN/ENO 225

SAVE 225
status hit HR 222 B il memory 48 Block funct ions for code blocks Block l ibra ries 415 m ock p arameter'S 252

235

forwarding

260

Blocks checking block consistency Ill5 companng 76 COlT'ting interfau 104 <k<cription 98 opening 106 programming description 106

CHAR (data ty(X') 122 Checksum 58,98 Clock memory 48 Coil !,<"et coil 142 set coil 142 singk coil 142 Cold rc<taM 380 Combining connections 70 CommenlS multilingual 80 Communication distributcd I/O 2g7 global data cornmunie'l1 ion 320 IE cOmmUnica liun 339 introduction 35 PlP communication 346 S7 ba, ic comm uni~atiun 324 S7 communication JJO Communication error 08 87 399 Comparison functions 193 COlllpr<.:ssing SFC 25 COivWRESS 282 us\.'<' program 84 Configuration in RUN 352 Configuration table 59 0Jnfiguring stations 58 Conn~cting a PLC 81

Index Conncclion lable 65 Conneclions configuring 65 loading data 68 Controlling 1 b its 233 10 Convers ion funclioll$ 207 ~tatuS bils 222 Counter functions lEC counters 186 ST MATT C counters 182 C PU hardware fault~ OB 84 CPU infonnution 82 Creating projects 54 system blocks 3 14 Down counting 185 DP maslu system configuring 292 description 29 direct data exchange 301 equidi'itant bus cycles 301 in network conllguration 64 isochronous mode 301. 302 DPVI intelTUpts 367

398

E
Edge evaluation description 152 Editor FBD clemcnts 112 LAD clements 110 program 73 symbolic 71 E).I/ENO mechani sm 225 Enabling peripheral OUlputs 90 Error handling 393 Example binary scaler 154 conveyor belt 260 conveyor connol I ~6 counter control 188 cdillng the message frame 413 reed 262 indirect copying of a data area .\3 message frame 411 parts eOUlller 261 save message frame 414 time-or-day check 41 1 Exclusive OR funclion 138 Exponentiation 205 Extended pulse timer 176

D Oata b lock funct ions 244 monitoring lind modifying data addresses 92 omine/online 84 open 246 programming 113 regiSlcrs 244 windows and views 11 4 DDta operunds 245 Dala Iypes complex 125 elemcnlary 120 subdivision 120 uscr-do;:fi ncd 128 DATE (dahl. Iype) 125 OATE_ AND_TrME(dalatypc) 125 [kvice name, device number 305 DillgnO!l ing hardware 86 O iagnoslic inlelTUpt 013 82 401 DiagnoSlics address 44 PROFIBUS 01' 289 PROFINET 10 30~ Digital flags 22 1 DTNT (data type) 122 DINT ehleulution 200 statuS bilS 222 D irecl dala exchange see DP master system Disable output modules 377 D istributed VO addressing PROFIBUS DP 287 addressing PROFINET 10 ,,)< configuring PROFIB US DP 292 configuring PROF1NET TO 306 introduction I'ROFIBUS DP introduction PROFINET TO 31

F
Fault-tolerant SIMATIC 24 First check 221 Forcing variables 88 Fonna! parameters 255 FUllction set FBD 429 LAD 425

G
Gateways 68 Global data communicution Global data table 322 320

"

.J<

Index

GSD fi1~s for PROFIBUS OP for PROFTNET 10 309

'"

H
Hardware catalog 59 Hardware config uralion 58 Hardware in\errup1.S 365

I
IEC counler functions 186 IEC fundious library 419 lEe tim~'r fllllctions 180 Indirect addressing 408 Input' 46 Tnsewremove module in terrupt OD 83 IN T (data type) 122 IN T calculation 199 status hits 222 Interrupt handling 356 DPV I imerrupt, 367 general remark> 356 hardware inl~rrupis 365 multi processor inlerrupt 369 synchronous cycle imcrruplS 370 time-delay imerrupts 360 limc-of-day imerrupts 357 watchdog interrupts 363 IP address 305 Isochronous mode 301

SY't~m function hlocks 416 TI-S7 conv~-rting blocks 421 Lood memory 26 Local data static 241 temporary 240 Local instances 242 Local time 278 Logarithm 205 Logical addr~ss 44

M
Main program ODI 270 Master Comrol Relay (MCR) 230 Mathematical function. 202 status bilS 222 MelJl(Jry hi" 48 Memory box FBD 148 LAD 144 jI,lemory card 25 Mc'1Ilory /'uncti ons FED 146 LAD 142 Memory re set 378 Micro memory card 25 Midlin~ outputs 150 Minimum scan cyele time 275 Modifying variabl e, H8 Module time 278 Modules ascertaining addresses 383 monitoring and modi fying 61 parameterizing 3H6 start add!\:ss 44 Monitoring variables 88 MOVE box 162 Move funclions 161 Multilingual texts 80 Multiple instance .e" Local instances , Multiprocessor ullerrupt 369 operation 282 Multiprojeet adjust projects 69 creating and Mit ing 57

398

J
Jump functions 227

L
Language smting 79 Libraries commnnication blocks 422 creating 56 general 53 IEC function block:; 419 miscellaneous blocks 423 organization blocks 415 overvIew 415 PID control blocks 422 re<iundant 10 (V I ) 424 mlundant 10 CGP 424 S5-S 7 converting blocks 420 SIMATIC_NET_CP 423

N
NCcontaet 131 Ne gation conveNion fun(.1ions 212

435

Inde>< normally closed (NC) eontact NOT conlacl (l.An) 134 R LO 13<J scanning ror "0" (FBD) 135 Network configuration 62 templ~les IW NOeontl1ct 131 Number range overtlow 222

IJ I

o
off-delBY limcr 179 on-deIIlY timer 177 Onl ine help 54 Open data block 246 Operating modes HOL D 377 RESTART 380 RUN (main progrnm) 270 START-U r 380 STOP 378 Opcrnt;ng modes of the CPU 376 OR functi on 137 Organ iz:nion blocks ltSytlehronous erron; OB 80 to OB 87 398 background SC:;IlUling OB 90 275 detemlining runtime 283 diagnoMic interrupt 013 82 401 in tem.lp\~ Oil 10 to DB 64 356 main prugnun a u I :no overview 97 redundancy error O B 70 10 73 399 rc.\tartOB1OOtoOBI02377 syDCh runou~~OB 121,OB 122 393 OutpuL\ 47 Overflow 222

['
Parallel eiro;uits 132 Parameter types 128 Parameterizing modul es !'cripliClllI inpu!.!l 45 Peripheral oulpulS 46
3~6

272 abon 08 88 399 PROFIBUS DP addre~~ing 287 configuring 292 isochronous mode 302 PROF[}'' CT 10 add ressing 304 configurin g 306 send cycle time/upd"tc time 3 10 ~ync domain 3I I topo logy editor 311 PROHN ET 10 systCtn de~cription JI in net ... ork configuration 64 Program cditor FBD ~lcmeDts 112 gcncr~1 73 LAD dements 110 Program ~lcmcnts catalog 108 Program exe<;UI;on errors OS 85 399 Program length 97 Program organization 271 Program processing m ethods 94 Propttm staru.~ 90 Program ~trucrure 270 J>rogrommin8 code blocks 106 Progmmming daU! blocks 244 Programm.ing net works 108 Project arcbiving 56 ero:ating 54 genC11lI 53 objKt h ierarcby 52 Project ve rsions 57 Protecting user program 2116 P1P comrlllmica ti uD 346 Pulse timer 175
Procc~~ing

updating

R
Rack failure OB 116 399 REAL (dat.a type) 124 REAL calculation 200 starns bits 222 Rcfcr~'Dce data 78 Resct 1:>ox 14K Reset coil 142 Rese! function 148 Response time 276 Restart ehaructcrisricS 376

Pointer IOcnera11\."lIlI1rkll 408 Power supply crror.s OB 81 Prioriry classes 95 Process image description 46 isochrone updating 371 su bproce~~ image~ 272

398

436

lnde ~

Restart tyl"'s 380 Re.ult of the l"gi~ ope.-at;on 221 negation (FBD) 139 negation (LAD) \3 4 Retentive on-delay timer 178 Retentivity 379 Rew iring 76 Rota!~ funct ion;; 216 Rounding 210 RS memory function

SFB 61 ReV PTP


SFB 62 RES ReVB

348
349

fBD

150
280

LAO 144 Run-time me!er

S
S5-S7 converting bloch libraries 420 S5TI1.IE (data type) 124 S7 ba ,ic ~ommunkatio" external 327 internal 324 S7 conununicatioD 330 S7-300 station 20 S7-400 station 22 Safety-relalcd SIMATIC 24 Scan ~ycle monitoring lime 274 Scan cycle ~Iali~tics 274 Smsor type 119 Sencscircuit, 132 Setbox 148

SFB 63 SEND RK 350 SFa 64 fETCH RK 35 1 SfB 65 SERVE RK 351 SFB 75 SALRM 316 SFB HUSEND 332 SFB Xl RD_DPA.R 388 SFB 9liRC 332 SFC 0 SET_eLK 278 SFC 1 READ_e LK 278 SFC 100 SET eLKS 278 SFC 101 RI M 281 Sf C 102 RD DPARA 38~ SFC 103 DP _TOPOL 320 Sl'C 104 elR 355 SFC 109 PROTECT 286 SFC 11 DPSYN FR 318 SFCI2D_ACT_DP 319 SFC 126 SYl\C PI 371 SFC 127 SThC PO 31 1 SFC 13 DPMRM DG 319 SFC1 4DPRD OAT 319 SFC 15 DPWR OAT 320 SFC 2 SET_RIM 28 1 Sf'C 20 BLKlvlOV 165 SFC 21 FILL 165 SFC 22 CREAT DB 248 SFC 23 DEL DB 248 SFC 24 TEST DB 248

Set coil 142 SFBOCTU l H7 SFB 1 CTD I S7 sm 12 BSEt-.n 333 SFB )3 BRCY JJ3 SFB 14 GET 334 SFB 15 PUT 334 SFB 16 PRTh, 335 SFB 19 START J.1fi
Sf'B2CTUD 187 sm 20 STOP 336 SFB 21 RESUlvIE 336 SPB22 STATUS 3.17 SFB 23 USTATUS 337 SrBJTP 180 SFB 4TON 180 SfB 5 TOr 180 SfB 52 RDREC 390 SFB 53 WRR EC 391 SfB 54 RALRM 374 SFB 60 SEND]TP 348

SFC Z5" COMPRESS SFC 26 UPOAT PI SfC 27 UPOAT PO SfC 28 SET TTNT SFC 29 CAN TINT SF C 3 CTRL RTM SfC 30 ACT TD., . SFC 31 QRY_TTI\'T SFC 32 SRT _DINT

282

273 273 .159 360 281 360 360 362 SFC J.1 CAN DINT 363 SFC 34 QRY_D1NT 363 SFC 35 MP _ ALM 370 SFC 36 MSK FLT 397 SFC 37 OMSK FLT 397 SFC 38 READ ERR 397 SFC 39 DIS_IRT 372 SFC 4 READ RTM 281 SFC40 EN_lRT 373 Sf C41 mS_AIRT 373 SFC 42 EN_AIRT 374 SFC 43 RE_TRlGR 274

SfC 44 KEPL_ VAL 397 SFC 46 STP 282 SfC 47 WAIT 282 S FC 48 SNC_RTCB 278 SFC 49 LGC_GADR 384 SfC5GAf)R_LGC 384 SfC SO Rf)JGADR 386 Sf CSI RDSYSST 403 SFC 52 WR_USMSG 400 SFC 54 RD D?ARM 389 SfC 55 WR PARM 389 Sft.: 56 WIt DPARM 3'XJ SfC 57 I'ARM MOD 390 SfC 511 WR_REC 392 St "C 59 RD_REC 391 SfC 6 Rf)_ S I}.'FO 277 SfC 60 GD_SND 324 Sfe 61 GO_ReV 324 SFC 62 CONTROL 337 SfC 64 TIMP.JCK 280 Sf t.: 65 X_SEND 32N Sf C 66 X Rev 329 S FC 67 X_GET 329 Sfe 68 X_PUT 330 SFC 69 X A[JORT 330 SfC 7 f)1'_PRAL 318 SFe 70 LOG_GEO 384 SFC71 GEO_LOG 384 SFC 72 I_GET 326 SfC 73 I_ PUT 327 SFC 74 I ABORT 327 SfC 711 OB_RT 283 SFe 79 SET 233 SFC 110 RSET 233 SfC 81 UBLK.c\.tOV 165 SFC 82 CRSA_DBL 248 SFC 83 RRAf)_f)RL 165 SFC84WRIT_DJ3L 165 SFC 8S CREA_DIl 248 SFC 117 C DlAO 33~ Shift function~ 213 stutu~ bill! 224 SIMAT IC counter functions 182 SIMATIC manager 50 SIMATIC timer funcrion 170 Single coil 142 5101 ulklres~ 43 Source Iiles up<Jaling or generating 76 Squa~-root extraction 204 Squaring 204

SR memory function FDD 149 LAD 144 Stan infnnnation DPV 1 interrupts 368 hardware intemlp'" 366 inl("fTllpt handling 357 mam prugrnm Oil I 276 multil)rocessof interrupt 369 r~stan 377 synchronous cycle intenupts 371 temporary local data 241 time-delay int~rrupts 361 time-of-day interrupt. 358 watchdog interrupts 363 Static local data 14 1 Status bits binary result BR 122 description 211 e'< aluating 224 fir<t check 221 OR 222 overflow OV 2n RLO 221 . ening 222 Status 22 1 stQrcd Q"crflQW OS 222 StQred overtlQw 222

STRIl\G (dam type) 126 STRUCT (darn type) 128 Subnel5 37 Subpmces~ images 272 SymbQllable 71 SYNClFREEZ 299 Synchronous cycle intemJpts Synchmnous errors 393 System blocks <.k.criplion 49 SY$tcm clock 21W System diagnostics 400 System functio o bloclul libraries 416 System memory 21

370

T
Temporary loc~l data 240 TIME (data type) 125 Tune of day 278 Timc S1amp conflict 104 TT'AF. OF DAY (darn tyfl<:) Timebn<ed rcadion

125

'"

off-dclay timer SfB 180 on-delay ti mer SFl::I IRO pul. etimerSFIl 180 Tint,,-delay intern,pt s 360 Time-of-day interrupts 3~7
Timer charactcnstic.

t:ser data area 45 L'ser data types 128

liscr program co mpressmg load R3


prQte<, .ion 82 1 tcsting 90

~4

elltended puliSC timer 176 Qff_dclay timer 179 o n-del ay timer 177 pulse rimer 175 retentive on-delay timer 178 Timer functions IBetim.,rs ISO SfMATIC timer. 170 Timing errors OB 80 3911 Trigonometric functions 204

v
Vari able dedarntion tahle Vari able table 87

100

W
3112,3113 Watchdog interrupts 363 Word logic description 217 status hils 224 WQn. memory 27
WRrm rcstarl

U
UDT (dala type) 128 Up counting IllS User blocks 99

439

Ab~viatioru;

Abbreviations

Al

Analog input Analog output Automa1!on system Actuator-sensor interface Binary result Continuous function chart Communications processor Central processing unit Data block Digital input (module) Digital outpul (module) Distrib uted 110 Data !"e<'ord Erasable prograrnmabk read-on ly memory Function block Function block diagram Function call Flash erasable programmable read-only memory Function module Interface module

CAD

Ladder diagram Memory card Master control rday Micro memory card Multipoint interface Organizati on block Operator panel Programming device Programmable controller Power supply Random access memory Result of logic operation Structured control language System data block System function block System function call Signal module System status lisl Statement list User data type Variable table

AD AS
AS-l

Me
MCR
MMC

BR CFC C' C'U DB 01


DC

MP] DB
0'

'0 "C
PS
RAM

0' OR
EPROM

FB FBD Fe
FEPROM

RLD SeL SOB SFB SFe SM

sse
STL UDT VAT

FM 1M

You might also like