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

Hans Berger

Automating with STEP 7 in LAD and FBD

51MATIC 57300/400 Programmable Controllers



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


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.



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



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


Ba.k fun<."I1"ns

Digita l fUllctioUJ


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:

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

of a Cooveyor Bolt

Control SY"t<m






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;


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

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


~ 8


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

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 ~



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


- .


......." ,'

proje ct



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



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

CPU MIh DP ma$ter:


al~~~rt PROf' I6US


, ,,

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


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

Project structu re

COOfogUf6 000111 .... s tation

is ""I up

Compiled configuration data ere located In 11>8




Automaling wi,h STE P 7

Slart netwo<l< conffguration

u " . ' p~r"m


Compiete symbol tab le Insert miss;"" objects

commun ica~o ns


Switch onl;ne

load s)'$tem data

SOU'C<Ioriemed pro-

M '

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




Creato program source ~ Ies

, ,



Define data structur..


program structure

1 I

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

Single slep


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



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


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




:Jnmidvctl(ln . . .


1. 1.1 1. 1.2 1.1 .3 1.1.4

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

20 20

2.1 2.1 . 1 2.1.2



50fh, a re


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



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

" " "





" "

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

Acruatorl Sensor Interface. Gateways



" " " " " " " '"

Communication . Introduction _


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

" 1 4.1

Communications Connections .


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


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

., " " " " " " "

" " " '"

J5 31

2.4.1 2. 4.2 2. 4.3

'62 1

" "
" " '"

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





J .5.3 !.S .4

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


2 .5.6 2.5.7


" "

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.6.1 2.6.2 2.6.3 2.6.4 2.6.5


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

2.7.1 27.2 27.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8




'" '" '" ,n


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


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


'" '"

31.1 3.1.2 3. \.3

" "


D2 D2


.. . .

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

3.2.1 3.2 .2 3.2 .3 3.24

" 98

.. ..


' 39

3.3. ! 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7

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

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




5. I I

'" '"





'" ,44

'" 112

3.4.1 3.4 .2 3.4.3

'" '"
'" '"

5.2.1 5.2.2 5.2.3

'" '" ' 48

' 50 ' 50

' .3
5.3. 1 5 3.2



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.1 7.7.2 7.7.3

lECTnners ..

.. . . .



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


" 5.5.1


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


'" .. , '" "

R.2 8.3 8A

'6 6 6. ' 6.'

6.2 .1 6.2.2 6.2.3

'"' ' 85



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

16' 16'


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



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

7 7. '

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



an AriThmetic

f unction
10.2 10.3 10.4


.. . .


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

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


'" '"



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


20' 21)'

11.3 11.4

FUIIClioDs. . . . . . . .

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




'''' 207
. 207

12. \





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

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


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


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

'" '" '"


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




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

m m m m

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

'" '"

" "

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


m m
228 229 229

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.


'" 23O


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

'" "


Scan Cycle Control



S7 Communication . . .


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 .


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

335 335


Program f unctioos


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

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

341 343 345

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


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 .


'" 3"

3S4 354 354

314 320 320 322 324 324

356 356


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

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



2 1.4





Parameterizing Module"

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


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


390 393

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


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




400 400 401 403


Handling Interrupl Events


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






'" 376
377 377 377


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




.97 "8



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


Supplemen{S to Graphk Progrllmmin1:


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.


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



Ascenaining a Module Addre.s




Bhxk Librari es . .. Organization BI<xks.


25 .1 25.2 25.3 25.4 25.5

'" " m

fun ctio n



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 .





25.6 2S.7
258 25 .9

'" '" m


27 .1


27 .2 27 .3

<3, m

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


Indu .. . . . . Abb re,'lations.


IntTOd uction


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


Structu re of Ihe Programmable


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


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

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



> Function modules (FMs);

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


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)



> 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


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


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

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


(N 46\ 1)


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.

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


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


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,


Counting. mCaliurcmCIl1, control. po,itiooing


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.


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.


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


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.

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.



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~


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



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-


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



.... .~


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








01".,. hlgllNghred

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

PleNa nolO. "".,. _


momc:wy _



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

In redlJClion

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


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

$}'$Iem memo.y rowns

in tI>e

TIm ... funclion$

""'" """""


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

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

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


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


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

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

load memory


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.



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



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


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,



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

or .I~H'
The OP .Ial'es are!h~ passive nodes on PROF!nus. in SL\1ATlC S7, B distinction is made


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)


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


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

c=-~., .w.

<-8. Io--r 200Et






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

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

dl" i e~





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.

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



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.

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:

Standard slaves


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





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:

DP/PA coupler. when PROFIBUS DP can

be operated at 45 .45 kbitls


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'


Serial <oM<Clio"

1.7 Gateway.


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)


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



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


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


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.


1.3 Communicat ions

l\ fP 1



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.

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 ;

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.




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


1 SIMATiC S 7_300/400 Programmab le Controller

T_bl. 1.1 Communication,Objec"

SfC call'


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


- --

FMS int'-TIace CPU, with


PROFINET 10 (10 controller)

TCP/lP and C OP.


CP343-11T 57 cr 4431 Advanced CP443 -1 1T

tah le,


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 .


Communication s ServlcO/"S



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

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


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


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.

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

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


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


" HPOI . L _SIO ( ..






., "'

n~ I





. .".
11 -+

1234 56 7

-, ._.

start add", . .


U.", P
~ s_ c "





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

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






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.

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


Logical Addu"


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 ,


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




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.

User Data


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.


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


A ddress Areas

The address areag available in every programmable cuntrolkr are


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.


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

Peripheral OUtpUT' em re",rve the some obsolute addr~sse s as peripheral input'.


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


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


Bit Memories

CPU i~ parameterized. Please rer.,- to Chapter 21,1.4 "Retentivity" for additional infonnation.
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


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


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=


Autum.llon LIcense Manager


SII\-IATIC M.nager

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.



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

Industrial EthlImet


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

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


"n,.,; k software)

Cont.l"or for.U d ota of

fl,. SI.\lATIC 3001400 slatlon

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

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.

""'!If\IDC"'' '


for tbe

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

Source programs

Contain.. for the compiled


. 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


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


System lurlctlnns System functlons blocks System data blocks Variable table$

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



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


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


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


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_


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.


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_


E d i ting Projects



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,


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




wi zard using fILE .....

''''cw plI.orrcr WIZNW.

CrT.Unlt a

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

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.

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

J\lanwglnll' An:bJvlnS(





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 .

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

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

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

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


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


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


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

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.


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.

I'n. m ~terldnlt


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


i\l c mitorinlil and Modifying



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




Confil:urlng Ihe :'Iiet".-ork


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:

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.


po po


Configuring th e ,,",f two rk lind

arran glnlllh~






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<'_ -, -",,,,,,,




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

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.


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 :

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


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

You require the follow,ng in ullier to configure a OP maRter ~y.tem :

i\ PROFIBUS subnel (i f not already avuil-

Kblc, drug th~ PROFlBUS subn~t frotn Ihe nelwurk ubjed ~atalog to the network window),

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





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


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

the communications SI"'lATlC 57 device ,




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


2 STEP 7 progralDming Sofu... rc


j ,

"""'~ I

,co< "".

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



f -

Sont _ _ _ _






~ '~obI"'~~_


TI :



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,

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-



for S7 connections:

00011><, to OFPP h<.,


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 ,



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-

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.


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

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:

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.


Loading th~ Connection Data



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.

---> --->


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




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


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

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



,,", eo~

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

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


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

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

,I M_

tw ,,,e, Of'



1" __

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

3 -1

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


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:

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

" " " " ""

' .1

" " ., " ,


" " "



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

' dol' . 0 -So..


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


"" ....,.""l

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

... , ' ...


~ ..

'...- ..

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

~ ~

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

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.


Httman mach in ~ inlerface monitoring wilh WinCe






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




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



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


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



InBlocI<s the PO




'~!.=~) ::o:



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

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.

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:

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.

. . ..
'"'' ' ,

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


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



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.




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.



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 ,


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:

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'


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

I 1 . 0 "LUnie_ _ itdo_up"


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


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




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~




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

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

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

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-



2.6 Online Mode


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.


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.


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.

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.

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.


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_


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

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

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.



(see Chaplers 2.7.3 "Monitoring aDd ~odi fyinK Variable." and 2.7.4 ~Fordna Vari_ a ble$")


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


You can initiate ",-'ent_driven compre~ing p<.'r pmgram wilh th~ c a ll SFC 25 COMl'RESS.

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


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


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


!l_d . .


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



"aj"" ;.

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



rbo: ""'"

Initial vaIu ..

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

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


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


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


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.


Caution. Y"u mus'


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


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

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


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 :

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]





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

While the foree function u. aclive, the foUo,," ina """liel:

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



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


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-


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


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

" --" "--'





." . .. '.. ..




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


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


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.


YOI,I Can now


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

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


2.7 Tdtina the Proj.rarn


......... v_.


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



, ,


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


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


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


L /


I C,.. I I

~ ~
M al ...


p ro_ in(ellupl




Error ha ndllnq






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


\)eCltU:IC a module

was bdng replaced.


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

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

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


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


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.



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 .





3.\ PmgramProcessing

T~bl~ 3.1


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


Modifiable .

Wi th ... tu>. update

16 to 2J

,or mOOe


tech no1_

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

"Co,. ' ~ I

1n th e C05e


toOB ~4, g6.g7

:~~c c. c

Sloer",' .



26 2) 2 5 2) 25 ) '

'" " '"

" "

2 to 26 2 to 28 2 to 26

2 <026 24 to 26

the em::>'"



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,


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

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.


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.

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



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


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.



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.





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.

Chapter 25 "Block Librarics" con tain s an over view of the ,tandard b lock s s"p phed in the Standard Library.


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


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



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


Block type Address Block head9.

name, Data type:_ In~;aliz . ~on: name. Darn type'. In;!;alizatTon:



END_Block Type

Data block. In"",m"ntal prog r8m ming

Data block, .ource-orlented prog ra m m'"g

Block I>c"dcr

In itia l value

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

t ype:~ tyP": ~






InrualizBtiQn: Initialization;







Initializa tion;



Fi ~n ,..,

3.2 StructUTC ofa Olock


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


3 SIMATIC S7 Program



Ifij .~ ..... _ ,"_. f~ ""' _"""

G"' od ~ '-""'


' ~991(1lll " '''''

', I211l ... ""UW ....



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

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.



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


3 Sl\lATlC S7

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 '

loc81 instances (function blocks) call"" in thi, in each case with the time stamp:; for code and interface_
in!tan~( ,
~ Atlrlb .. u.~


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.


TIle inttTrace of a called block is younger Iban the code of the .alhng block.


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


Block In tufacc


The declaration table cont.aiM the interFace of the block 10 the rest of the pman.rn_ It consim of the block paramCters (input. ou!pUt and in. OUI parametcn) and al", - in Ibe case of~ lion bInds - the .Ianc local dalll.. The temporary local data, wbich. do not baSically belong 10 the block interface, are also bandied at this point. The block interface is defined. in the intcrfa.e window when prognomming the block, and i. initiali~ed with variab les when the block i. called (~ce Chapter 19 "Block Par.uneIen;").
The Program Editor checks that the block

> 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


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

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.



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"


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,


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:

. ."

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

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

_",",,' [M ' _J




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

'(~["" -I

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

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

( "' ~ l

o CO!


.P". . . ' [nol

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

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


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


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.

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.


m oc k Windo"


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.


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:

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


3.3 Progro.mming Code B loch


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



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


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

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


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

M __

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


t ]litu ....


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


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


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

St.l ic 1 1data <>Ca



,. ,. ,.
,. ,.

Temporary local da .. Fune<ion ~ alue




,e ,e


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

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


th~ fi~lds

for tbe nl:l-

wort: tide. the network cmnm~n:. and the fkld to.. the prognm entry. in the program SCCIion 01

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





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

" 'ith L'SERT

,"~c-n, In

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

l"1:TI'oORK. Tbe Editor then


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




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.


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

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

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.


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

Si:nJ>1< coil

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

(e.". ncgouonJ

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

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


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

: ''" ,
Flilun ). 7


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

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


" 1= 'CDeof LAD Program Elemcn"





I:>c~mpl tj;


3_3 Propmmina; Code Block$

" . lwo~k




to ' Oy.

. .,


~ ...


h~v ..

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

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


u.<> .... l .

- ... u ..

{p -



i."'~ .~.


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


re~t dctions

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.

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,

'Vhen LL.ina


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

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


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

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


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


are simpk


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

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


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

lli~ logic

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

L L mR L
> .,

Slmp!e bo x..

8 inary operand





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

Counter o p-eraoo


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

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

fll<d. "OXO,
(~ IO.

tunc,;"" hlock calls)



, eo


= -




in ' in2


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

3.4 Prognunming Data U I()<;k.

~ o. ~

' E>'


". "


" ",



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


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


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

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.


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

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.



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

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;


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


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


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

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


3 SIMATIC S7 Program


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


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





- 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

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



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

Address;n!,: Va riables

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

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


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


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


l)'pC w ith 16 bit,

ID g


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



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




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

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)


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




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

> CompLex datil


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


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

tJata 1)l'"



BiI' [6R1Xl, 16#00

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



ch ara,tcr (A Se!!)


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;


(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




(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

12 3.4567")

(16 bits)

nme value in S L~lAl'lC format Time


SST SST!MEif2 h46m30.

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


(32 biLS)

in lEe fo. -


DI" I ~JO.(JI-O 1 DATf-'1'2168- 12-3 1


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

for value r.mg~



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.

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

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.


, "
Sl or $1


4 2 """

Doll.r sign Apostrophe

L in~

SP or Sp SII. or Sr


fel {lf)

No,.. page (rt)

Camaie re"'m (LK)


S'T '" $t


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.

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


ASCI! Cod.


BCD num""r, 7 deeadu

Byte m


Bytn m+3



24 123

20 [ HI

Om type INT

15 14 ...

D~'" typ"


3130 ...
1S 1

11> 15 _

d ;;


2 ..2'"1'" ..

... 2'2' 1'1 :

... 0 '"

... 2322

3130 .

Data type S5TIME

15 14

... 0


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

1514 .

,, 'n !)

Data type TIME

3130... .16 15

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

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

... 6 " " .



... 1615 ...

, 0


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

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


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

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

A \"ariablewith dara I)'pt: S5TIME is used in the bB~IC iani'Ja!!C"S STL, LAD and FBD to ~et tbe Slil.1ATIC timers. It n::ser.o:.I one l6-bit word with I + ] decades. The lime i, spcciJied in bours. minuteii. sccond.$


and milliseconds. STEP 7 handles convc ... ion

in to imernal repre5enta.ion. Internal

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


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

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





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

t> t>


A~ D

TlM r

t"". .

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

STRING Lnaraeter string with up to 254


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


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

> ARRAY A rray variab le (combination of variables of the sam e type)


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




Tabl~ 3 .~

lOxampl or the Dcda"'tion of DT \ 'mable< ~n d STRL'IG Va".hk,

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

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

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

a.too form8t STRING


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


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

Hc ur


Byte n+3

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



Minute Second

Byte ...
Byte n.m+1

mrn <;haracte r

Byte 0+5

~yte n+6


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.



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


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


0.6. 3.0)

Amoy ,-ari.ble with 24 REA L clemenTs


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

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



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

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

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





"''''' '00'

S5TL\IE ~ Ss





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

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


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:

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.


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

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

Tim ~n

S1.artmg 5 different kinds of timer. resetnng and s.eannini I timer. IEC liIn.ers

Counton Setlwg a coumer, up md down counlin&; resetting and .scannmg a counter, lEe cOunters; fud eXlllnpic


4 Binary Logic Operations

Binary Logic Operations


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



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)

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

Bin ary operand

- I I If-Binary opeI';md


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

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.


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

' 0'

" '"






,, ~

oc Wa'~d


~ .I

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

" '



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


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)



NlICWOl1< 1 tact1






( }--I



I I I I I I I I Cl


Coltl Nelwork 2 tllC14 Contaclt5


C." ( }--I

Contact4 ContactS



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

Contact3 N,twork .. Contact4

""" )





Contact3 Colt3

I J~t5 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




I ."".on I


~r- I
"""""' I

( )-----1


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

"'" )-----1

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

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

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


( )-----1


( )-----1


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

N"twori( 10











OO.~ct3 NOT~I__________ ( )--I



Contact3 Contact4
Co~1 0


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

thc scan.ned operand is negated prior to exec lltion of the logic operation (see below).



Exo!m;w_OR fUDe';""


Th e numkr of binary ftmctions anu the scope of a b inary function are theorel ically unlimited: in practice. however, limits are Sd by the length of a block 01' Ih~ size of the CPU's main memory.

Scanning And u,il:ning signal states Before the binary functions perform logic operation, on signal states, they scan the binary operands SliMe function inpllt~. An op<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


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


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



Ch""k fM .lgDal.I ... "1"

11 .0

Function box

" " "'


, , -\1



C bd.: fo r . ignal "at< "0"

s.n.".. -~
" '



.....,, , \1





" .,'


Fun ction box

Function bo"

Function box


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-


42 Binary Logic Ope ration. (FBD)

A.",' n fu nction
Netwllrl< 1

Inputl Input2 Input3

Network 2


Inputl Irwu t2 l"l'ut3 Outpotl



-' 1 ..


Inp<J 14 InputS

==d , ~ OutPUt2

Input4 Input5 Outpul2


OR fu"<tlon I Network 3 Input l In;:>ut2 InpuO

Network 4

InpUl l Input2 OI.ltpul3 Inputl Outp"O


I nput4 ~

> I

Input4 OU\j)IJt4




E ~du. i, . _O R


Netwllrk 5

Inp"tl Inpull
Network 6


Input t Input2 Outpu l5 Input4 Input5 Outpu\15



Input4 Inp ul5

=:d. xoe ~OUtput6

, 1 ','



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


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.



,""'" Inpout3


.., I



4.3 TakinJl ACOOWI! o f me Sens<>.-1'ype

NAND fUn crioD N. twork 7

Input! Input2

~ """"

InpY I1 Input2 Input3








N. I _ 8

Input4 Input5 Input6


Input5 Inpul6


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

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


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


4 Hi"ary Logic Operations

, , ;' ,

(; .., I : Bo,h .. n.on a ... 1'0 <on'uf!

So1/) Ufl;o",


" "

" .,. .,.


, t ) "''',,,''ed ,1 4

Cu. 2: On. ~o contaN ond un.l'C <un(.


, ., ."" "".

-. , . lr , " .,." 0

Bolh Hn"""" actlv. ,to<i


1 4

plcl<8 up

~-jllu" 4.~ T~kjng oontact~



Conr. ctor
pict. up


Account of tho Se""'I Tn'" (LAD)

10 you for this purpos~.



An KO comaCl rerurn "1" if 'Me ,cann~d input is al.o " I ". An NC co ntact return;; "1 -- if !bc ,canned input is " 0". In this way. you ~au al,o

directly scan input' that are to trigger acli, ities when they are "0"' (z~'TO-acti"e input<) and sub'equcmly re-galc the scan n:suit. The ~xampJ" in Figure 4.9 shov., programming depcndent on the sensor type . In (he fint "a,e, IwO NO contacts are connected (0 thc programmable controller. ant! in the second case one NO contact and one t\' C ""uta<;t . In both cas .... '. B conta~Wr conneclcd 10 m OlUput i, to p ick u p it both , enwn; are ac!iva!cd_ If an NO contact is aC liva(ed, (he sig nal ,tale at the input i, "I"', and Ihis is scanned with an NO contact so thaI power ~aO now wh .... n the nsor is acti, -ated. If bolh NO contacts a ro a~1:ivareJ, power flows throngh the nmg to the coil and the ~ontactor pich up Ifan NC ~on1 aCI is aCllvatcd, Ihe .ignal sta(e al the inp "l is " 0 " In order (0 have power flow in Ihis e"l'e when the ,en,or i, activated, th~ result Il1U';I be scanned with an NC conlaCt. There fore, in (he second ca,e, an NO contact and an NC contact mn,1 be connected in series 10 make th .... contac(o r pick up w hen botM senson; are activated. Programmin g with FRD If you "u-u~tun; Ihe progrnm in ,uch a way that you wa nt a scan result of "I" when a sensor is

ac tivated in order to ~ombine IMat <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'",!>


4 .~




---7) H "'

c.", 1 : One ~O <o ...u .mel .. lie NC r.n._..


0 4.2


" "'"


,- T




" "'" " "'

-----... , ,"


0 .3


" '"










" Coo


Fljtu .... 4.10 Taking Aerow" of1h< SeruorT)-pe ( ~ FBD)


Memory Functions


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.

'1lH: following memory functions are 8Y'Bilable ~ The single coil as an Ds>ignmcni of the RLO

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


c,calwl\ions ofllle


The boxes P~S and l>."EG ... ..die nalua lions of opC'l'ilnds
~ di~_

Midhne outputs and edg'" ",valuano!lS


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.


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


Set and Re.et Cull


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

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



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

Contact1 Coil1 Contact1

Col 1 2



1 )--I


n n



Coo"'" {",)--I CoO,

n n
i i



l lil




Ulet '


~ "'.



I I --, I I


ConlaCl1 Coil1



,teet2 I


(0)--1 CoO,

N_lwork 1

H """ """"'" I I

"'" 'J

c~li10 $)--1

.,..,.., I ""'" I """"" oj CO.

Co'1 9 CoillO Coi l11

5. 1 Sin,l. Coil. SCI and Rc= Coil


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

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


m~."...ory op~rand

R S ho ("

," ,
"" ,


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

i i





Ne twork 9

, ,,',



= I
Coil1 2







N etwork




M. mury rl!ootion ,,-i,b latchln



If Network



'[j~" : C~:14
Network 13




( )--I



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


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


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"

~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


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

Network I Inputl Network :l Input1 Network 3 Input2

Ou!p~ t l


l"Putl Outputl Inpvtl





q I

, r:l'


, "" n,


Ne twork 4 Input3 Inpu\4

O ~tput5



Input3 Output4







- I


S<t and ...1

Network 5 I"putl NetworkS



Inpull Ocotpua Inpu!2 Output7

I ,

i [7]





. "'"twork 7 Input! _ Input4

Inpu\3 Input4 Outputll


Oulput9 R
OutputlO Oulput11




5.3 Ass;!!". Set and Reset (Hl D )


S Memof)' Fun~Iio~
~ . 1.2 S ~I

and Rent Box


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

o f the 10llie operati on going into th .. box



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

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.

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

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

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




OUtputl2 InpU!3

In ....!'"






~ ,
t tjlu re


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 .


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 .


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



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


Netwo-rk 15 Midline outp uts (2)

>-M--j l~1 idl

Ml d tln ~

Midl"OOI: :'__-.:~~I3ct6




ou' uti (HID)

Network 12 Midline ""t puts (1)


" "

Input2 Inpul3 Input4

Inpv~ _






M"" 1 " I ---f'" oo' , ~". ~ Midline!


. :


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




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


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


Edge memory M
N<l:"",eodG" ora" "p<rand

- LM-'",_ --'

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


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


E<l9ft memory till



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


E,;g....."""'Y bn

~ M ~~G 0 ~


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

Blo ary Scale r


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.


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.



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.



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





' I EdJl' ."OI"'110~.~'i\"''""'::::::=~,,:-:==:::~~=::-:'':====-:=~==::-~ Edll~ (I,. 7

'. ",.two", t 8
. dluallon In powor now

Edg9 meroory bi l


11--1 1

I--"' "'---" " -Ii~






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 )


- -'


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' ~(


,--_ e~ry_2 M--1

S. IO llinary Scaler E>.llIilpl ... (LAD)


SnlU IJo n In FBD


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

<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


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



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


, , ,






- Mo~" , Network 17

'. ~ ':.1


Binary scaler with memo!), boxes (2) Memo


".'. .: :" - .': :' .-

-. .... - .',.

. ',"


Network 18

.. dg.... v alu..tion (1)

-.. .-' ,.

19 Binary s caler with e dg e ltValuation (2)

OUl putO



I - I

Network 20 (next n ..twor1l with jum p I. bel)


... ",., ...... . -.-.-;.' .. - ';' 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:

> When Ihe bell is empty. the controller req uests mOI~ pans by ;:;suing the "ready_ load'" .ignal (ready to load)

\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


Basic_ ,1 Set' the controller to the basic <late


Mati on
Swit~hes lh~
ti (ln~

belt on. ,..,gardless of condi-



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




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


is located in a


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.




I .. .


iti .


3.6 Example ofa Conveyor Control Sy stem

fC 11 Co"vo)nr <o~tr oJ ' )."""

Networ1< 1


N.twork 2 PBrts





~ _Lo~_N




EM- Rem- ?



i, , " ... I :'......... .,',",' , .', ...,

.- "

to re"""1o



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



N etwor~

Belt F."d~ to load R"ad\



a""ic.J '



, " ,



, ,

Netwerk 5 Controll taR molor


EM_ Loa




.. .... .. .... .. ':'-'! .. . .. ,;.;.


... .. ., "



' .', '.!-'~





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


oonlNI .,'".",

Network 1 loood port.

light_ barrie r 1 Baslc_", IMfaull l Network 2




Pam ready to remov..



Re~dy ~

BaSic_ 51 IMfau!tl

Network 3 Remove parts l oad

Remove BaSic_ 51
IMfau~ l


, , ,



Network "

Belt reedy 10 load

Remove Beslc_",


Reedy to load

load /Mfault 1



Network 5 Controlling the belt motor

Remove Load Man on ISlop



B,, ~


Figure S. 13 Sampl e COIweyor Control System (FBD)


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

MOVE box Copy orerands and vari"blos with elemen. tary data lyres
SI'C 20 BLKMOV Copy dat~ arca

Bloch prob'l"anl .




SFC 21 FILL Fill data a...,a


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



D~ta In data blocks

:' ait memory


Constants. pointer~


.. -.

r' Process~ma~a.t""'llt
and output tabtes l' Bit memory



"System memory

Data in ,;"t8 btocks Wotk memory

Peripheral outputs ModutM


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



ProC l/"Sslng the M O VE B ox

'" "





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,


01Doubleword n 01
Word n

24 123



'" , ,.> '" '"

(n+1 l

01By... n 01
Bu"', Accumulator 1

16 115

,.) ~



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

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



MOVE bl'" In a logic circuit (FBI

ENO := ' 0

The cor"en!! o f input "ord l W 0 arc mm'wto

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


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


M o \ing Opt"noodl

In addition to the operanJ,j mention<,d in thi s


bn ~

In .. run," (LAD)

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


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.
Muv i n~

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




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


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_


I'lD n PIWn

Pro "
O'Q. "

wading a ~ripheal input byte Loading a pc,;phcl'lI.l inpul word Loading II periphen>! input double"ord



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


;\ \'(/\'inll Con f tunt$

PQl) "

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

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



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

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

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




A,'1Y I'ointer



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



Paramc',r SRCBLK }1FT VAL I)STIlU<




Data TlP<'

to~t""ts, I~ripti"n ~ource

~, ,,~

orc. from which data arc t(} be copied

.. ._. . . .

" "'


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










Pil1l8.0 WORD I Input "'oro IW 18

1'#11.0 BOOL 1
Inpul I

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


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)


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:


> 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



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

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


PIIM 84 .0 BYTE 16 -



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

P#M 80.0 BYTE 1 -



f- FW 84 Bl K f- P#OB I 24.DSXI6.0 BYTE 16

s ." .,. function. for dot"



N work 4. .

Exa mple

lorSFC 20 B=',',.,o',O,,-,;;-__, ,
SFC 20




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


for SFC 20 RLK1>tOV .nd SFC 2 1 FrLL

mentally). The following actual may be assigned:


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

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~


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


DB 12




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.


'" "




------DB 14

-, --'

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


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


Programming a Timl'r

Extended pulse timer; On-delay timers Retenti,'e on_delay tim"," OfT_delay timers


Rep reseutado n ofa


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



, ='" e

r""", 0 1"'....00

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




D",a Type Doscription


Sta n inpu'
t mro,ion of linK- 'I"'cification

" " BCO " ,=,



Ro.<t input Curren' time ,.,.I"e in binary Curren' ,ime ,-,u uo in BCD Timer .tatu,





Stan u-.- by Of>'if,-ioa: ~ ( ...... coil " 'id> lim. mock)


"""", ,,,
TImer Dl*and


R.... rim., (I ..... roil)


TImer operarld

Ch"d limor 1100UI

("0000'..". NC """,""")
Road lime at binory ....1"" (MOVE 1>0>:)

TIme< operllrld


~l ,ure

7.2 Individual Elemen .. of. Timer (LAD)


- 'N




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)

Reid tIn><r (reset coil)

TImer op&ralld

~ TV "


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



Me" 0"' t- DigtIaI opet8nd

' NO


7.:l Incli"d",11 hl.menu ofo Tim.r (FBD)


" I" to 'W '; all "Iher tim~..,; .llan when goes from .'{)" to "I".


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

Spe<:Jf)1 ng Ihe Du n don

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,

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.


Durotion - 20()] I>:~ J)uratiOD - IOIO""~ OurohOD - 0100t,,,,,

100m. TIme base 10 It1$



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


F 1:=3

b 1----=1



Ot,deloy tun<r
R.... nti'e OlI-dd.y \"'10'





I=-- '

F- r


Th\4I vel ..... In ace

riffle base In Bee

2. 1 3. 10.

'-0.1 .

0.0\ s


7.~ o..criplion of the

!JUI in


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

( 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

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>


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


Pulse Timer

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


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


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.


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.

SIgnal state at

I , ,


\he SUlrt InplJl Slgne l .tate at

I ha Ruel inp ul


~ '-,




f lau .. '.6 &h:tvion.l Cb.ratlmllic. ",hell Slanillj and ROK1Iln8 _ Put.., Tun ...

7 Timen


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


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~


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

SigrwIltate 1tI.. Start Input


" -1 - -

. ,



r- r---.

Signal ,18 1<' 81 the A.aHllnp \ll

0 ,

""" """'""



DO /


T imer status (check 10< "1 -)

I 0I , , , IP P I ,




I p , I 10 I



1 PtogrIJIr)ItMd dunIJon


7.4 On-nday Timer


On-Delay Timer

lim e value shows the amount of lime still

r~ m" m mg ,

St.rting a n on-delay

Rescttinl;:: aD

OD -dcJu~'


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


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.


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"


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


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


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.

Signal stale al Ih" Start inpul S ignal stat.. ,,, the Reset input T imer running (intemal) Ttmer status (check/or " t ")

i 'l

" rl--j H o I I I , , ID ,


p 'l

I 0





I I 0


" I "II n


D 0, ,

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


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 ,


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




h r



Time r ru nni"l) (intoma lj Time r status

(check 10<

-" j





Figu ", 7.10 Behavioral Charaoteri" ie. when Slattin g and Reninl!" .n Off Delay T,mer

7 Timers


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.

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,


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


SfB 4 TON is adiv~ in START and R UN mode. II is T~set on a cold sinn.


Off_Delay Timer S,r B 5 TOI'

~.~",;~ D ooclaratioo

Ue"" ripliG1l

TEe timer SF'B 5 TOF hu, the parame ters listed in Tabl~ 7 1






Pulse knl(th or delay durat100 Timer >taWS Elop=:i timo



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


, hr ,

.__ t ___

,, I .

, ,

r't Prrx;ramm<>d duration



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


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


(inltte eutnple: updown countc:r)

LAD ",presentation

C ounter op ... and


=, =,
FBD representation






'" , =

Counter 0 . " SCUD


Programming II Counter

ev , =


= -

Oat>. Type Description

You can perfonD the followin g operations on a coumer:


Set counter. specifying the count value Count up



> Count down

I> I> I> I>

,y ey ey 'CD



Up COlmt input


Reset cOlUlter Check (binary) counter status Check (digital) coum in binary Check (d ig ital) coum in binary-coded decimal


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

FIgure 8.1 COUllter III


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.


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:



Prugr~mming aCmlll!er

C"unt "J> funetlon


(wunt ur ooil)
Coon! 00"" fun< tion (COunL down coil) Sct = lcr with ,-Ill,," uf cum;nt oount (""t counle>" "eM) with c.-.un,)

Counta< o...,...,.,,:L

Coo,,"'r ope"',,!,!

---{~)--I Count VlI1u.

Courrter operand

R<t Cco.Ultcr (rcM:t coil)


COLmta, """",00
Counter ope"",d

(NO """""'t, NC contact)

R""d coun L.. bi nary valu<
( MOVE box)

t""""" ".ru,


'"0 0"'
Digital operand'

CountS< op""md

'" "

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



Coomer op9ran<i c oum value



Re",' counter ("""" coil)

Chee ~ counte, .tatu' (d ir"'t or nC"tc-..J binary inpu')

Coullt..,,- operand

CoI.l nte, "pe ran<! Count".. o.p<j,and



Read oount .. binary v.lue (M O VE box)

COtlfl!", operam:!


MOVE 0 ",

Oigital operand


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)



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)


Setting and R ese tt in g C ounters

Settin g countH.

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.


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

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


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


Checking a Counter

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

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.


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;



Do"'n Cnunter

C b N"kinll: the counler



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

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


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.


exccutcs in START and RUN mode . It is reset on a cold s tart. Up/do wn C<1untcr Sn3 2 CTUD



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,


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 .


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



Network 1 Counter cont,ol

"'""' S_ CD




c' tCV_BC D


( )---j

Quanllty -




, ~


'" "
EM_ l B_ N

"" ~

Netwol1< 3 Select duration

lbarrl Du," 1 lba,,1

Dura 2


#t BOOl

'" '"0 '" '" '"


III Durali<ln

'"0 00;


D u,~ tlon





Fi\:ur. 8.4



#I Duration


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


L barrt
5..,t -


QuantltY:-=t';V~...:O:V:,'o'-9J-=_-<i':'":"M='j : Q Ackr>owl R _
Network 2 Activate monitoring


Lbarrl -<j"
Network 4



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-


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


lati cm possibilities beyond the basic ari thmetic to include. for example, trigonOmet. ric functions.


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.




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.


Proce5sing 11 C lilUplIrison Function

to C-T)

Co,nl'Arl'OD .... , (," eumpl<; """,pariSO" for equo!

LAO 'OpAls"ntation:

='"' '"'
- 'N' 'N'

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



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


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.





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



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


92 is equals to 120:

C MP --1

MW 9 2

Comparison a ccor din!/; to I) I<,-'T


'N ' 'N '

.. ..


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



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


'N' 'N '








FIgure 9.1 Comp.ri>oll Fuuctiuu Example.


9.2 Description of the C<.>mparison



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


Desnlptlon orthe COmpariso n


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.


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-

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.


You can find a description of the individual bits in eac~ data fonnal in Chapter 3.5 .4. "Elemen tary Data Types".


I'u n cd on




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

With data type

Subtraction M ultiplication
D ivision with quotient os res ult D iv ision with remainder a. ,,:>ult







10 Arithmclic Functi{)ll5

IF EN "" '1 " or not wired THEN

OUT :. IN1

> Invalid REAL number in a REAL calcula"

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:


Range violation (overflow) in tNT ami

DINT calculations


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.

MW 100,~

Add.tIOn according to D1XT


'" '" '"


'" 0

r-- MW 102



MW1~ j IN2 :~1 250

0", '"0


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.




"Global_OS". MthVall "Gklba l OS". AI1thV"j2

- >N,


"Glooal OS". AI1IhReSult

"GIobaL DS" , AI1\hVall "Global_OS" ,

At1IhV~1 2


'" >N,

0"' '"0


"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


liActVa l liFactor

'" '" '"'

OC , #Oispay


liActVal #Factor

'" '" '"

OC, -



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.


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


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


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

~dd illon


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


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



::. Squaring, 5quarc-roOl e"lntction


function 10 base e. naNrallogarithm


All mathe1TUlticai functio", procc, .. REAL


IF EN ,,- "1 - or not wired

THeN OUT ;.. Mfct (IN)

IF erro r occurred


11.1 Procening Function

Rt pnsentulon


Mat ht'1II0tlc!l1



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


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


MO 110




MO '04

The .quare root of the value in variable ":-'hthValue l" is generutcd Hnd s10TC<l in the

variable 'MilhRoo!"".

"Global_DB" . MathValue '

"G~al_OB .

MathRoot "G lobaL Oe". MathValuel


'N 'N

OUT ~ MathROOt

" GIobaII DB".



' NO

Expo ne nl


"Re.llh conlalns the i>O"'oeT of e and




'N 'N



'N 'N


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




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



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:


"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


Table II.I Range of ate functions Functioo


Value Returned
- ,,12 to ""TtIl


I to + 1
I 10 +1


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,


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

/NOItago "CUfT(lonl

'NO '"' 0"'I- Jtt..REAL 1 'N 'N'



'NO 'N '"0"' 'N



N e twork 5

'N 'NO r-#8_Powe, 'N' QU, IfLREAL2 'N' Calculati o n of h ypota nu ll

1- '0'




, , ,

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


!in.!! IOlilo

You Can calculate any expon=tial "RIlle the fannula


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.


In the spec ial case for bllse 10, the ("nnuln ;, u follows: IS CI "

'" '


- 0.43 42945 . In"


II Mathematical Functions

...!:'ampk. of moth function.

Hetwort< 4 Calculation of r
cH~. pow~r

#Voltage -





I- ill_ REAL!




'0' <'
OC; -kt_REAL!

'" '"




'" '"


f-- #B_Powe,


N t twort< 5 Calculation of hYPolanu. .



'" '0'


f-- #!_REA1.2

o c;

'" '"










0 0; - " c


Flgu,"" 11.3 fu.ampb of \fa,), om. tical Function. (FBD)


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

3 d ee.

'" '"




t 2.1 Prucessing



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"





0 '"


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

I_BC D eN 0"' eNO



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

OUT:" Confct (IN)
IF errO r occurred


ENO ;= 0'
w,\b Con







.. ""

"'<'"ion fun<ri""


12 Conve,..,ion Function,

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

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

'" '"


MO 122 MO 120




'" '"

0'" '"0


MD 111



"Global_ OS" ConvertREAL "Global_OS", ConvertD INT


RF;AL number.

. The absolute ~a lue "generated from 'anable I'DlSplay.

'" '" '" '"


0'" ,"0


"Global DB", Convert REAL


'" '"

'" '"0
#Display #Dlsplay



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.

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


Conversion of lNT and DINT Numbers

Tobt. I' 1 Con ___ ,..;on of TNT and DINT Numbers

D~I .


Type Cmwor_ '0<

Dat. Typ<: fur



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

~, ~,






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



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


I scts nO S\aluS biN


12,4 Conversion oCRE.A,L l"llmbers



12 2 Co."",,ion o f BCD :-.Jumhers

IJMa 1'ype nmvo:r.,~

BCD_ l

[}at" 1'ype for


BCD 10 l"'T





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


Data Tyl''' for





ial<ger To no,-l lo",.,. ,n '''ger To nD.. l inleg,'T

Without TOundinlj:

me REAe


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

R ounding to the



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


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.

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.

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

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



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

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)

F BD representation ;


, .. j -,'.

'" =," '"' = 'N





oc, f-'"0



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

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

uf Shift Function, Double"'Ofd

Variah l.

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


'"' '"R

SIll._ [JW


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

. .


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.

'" '" - '''' "

MWl30 -

'"0 0"' : - MW 132

MW 130


='" '"


" ' "0

SHR_ OW "G lobal DB". ShiltOff-



Shifting doubleword

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


'" '"0 '" 00' r-"


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


'" '" "

'"0 00'




W# I 6#2

='" '" "


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

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


S h ift doub lf ..o rd n rl . ble 1 Ibe 0


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

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

variable A-, D "


ooubJewurd v"';able

14.1 Processing Il \Vord Logic Operation

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;




FBD ,"presentation;


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 ,




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

, , , , , , , ,

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


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




'N 'N ' 'N'

MW 142

- 'N J.tw 140 _



Van ablcs wtoglc'\al l and \\ LoglcVal2 al'<' OR~d bu Cor bu lind tbe ",.ull oretl in W1.Oj;ICRCi lt'.





'" 'NO I - MWU2 '"


"Globio l OS". 'M..oglcVal j .


"GlObal DB".

"Gk>l><!ol OS" , lNloglcVall "Global OS". WLOQIeVal2


'N ' 'N'

0"' I - WLogkReall


'N' 'N' 'NO

0"' f-

"Glob31 OS"


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

iIIflput ll'Masl< -

INt lN2

OUT I-- #Su".....



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 .


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



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


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



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.


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


first Chock Re<uit of logic


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



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.


Condition code (itala,) bil 0 Condition code ("atu,) bit t


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

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

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



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



< 32768

32 768(MUI.._I)

" ,

- 32 768 to

, "

, , , , ,


The ,ult i.


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 ,

( )65 536 Division by Uco

, " , , ,
0 0

" , , , , , , , , , ,


-1'0-2147483647 >+2 14 7483647 (ADD D J. SUB 01) >+214748 3647


2147483648(DIV_ DI)

H " 194 967 296

Di v i,ion by >:oro (DlV 01. MOD 01) Comp. ri.on

, , , , , , " , " " " , " , " , , " , , , , , , , , " , , , ,

ce. ov


0 0

JU:AL c.lculation

The ,e<uit is:

+ DOnnalized '" denOrrn.'l1ized " zero nonnali,ed

ceo ce. ov

+ infinite (divi. ion by


infinite (division by zero)


imalid REAL number

" " " 0 " , , " , , 0 , 0 , , , , , ,


, " 0; , ,

The rult;s:


ce. ov



0 0

gre aler than

1 5 than
in,..lid REAL number

, , , , , ,

The resuh is:


ceo cu OV

+ 1 to"'32 767 - 1 to 32767 ( )32768




The .e>ult is:


:-a"c -D


ce. ov


-1 '0+2147483647 110_2147483647 ( )2 147483648 Word logic



, " , " , ,

, ,

0 0

. Shirt function
The shifted out bit io: 0'. CC" CCI


, ,



Th., result is:

Co> CC,


with shift nOln be. 0

" , "

not zero


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


A cu=nt OOW$, o r the check

is fulfillw wben

> 0


--I f <0


--I f "0

--I f UO

--I f ov

--I f -

" --I f --I f Ftau"" 15.1


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



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

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

Su !n~


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



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

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 .


15 Stall>.' HilS

Is ENO switched?



Is EN switched 7

Is EN switched ?


Is EN - - "t " ?

BR :- ' 0' BR not a ff9CtBd

Is EN "1"?
BR corr ... SPOMS to tunc-


,. "0 "

tion Fi\:" r.
1~ .2

spo nds to func lion



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 .

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


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 ,


-it"' H - - '" ~ MD"1)}.;:::' 'N1 -, -.tOO-.,, . - 'NO ;~'.., -.I.i!~'

,.... ,.



Coo Utett


'"0 0"' f-#CREAl

#\ R EAL

'" "




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

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


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


:i" '~---1 I t/compVall - (N1







tiompval2 -1.""~' '


: !'I.~.qrI( 2. Jump to "'II (5 not execut"d

1/-" ~lAcl f-I___________ (

. ~!,rk




3 Uncondttlona( Jump

l~:+;;~~~~ ,_~-----------------------4(~~H ~~ .
CondlUon ltlJump 11 RLO _

Entry- 01 "'1 2

Flgu ," 16 .1 Jump FunctiOn< Exa mp le (LAD )


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


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~


~=l'; ;'~ N IN2


N.twork 2 If jump to M3 Is not . " e cuted OutputO & InplllO


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


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


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



r ep'a~entat i oo


A.Unt. MCR o",a

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


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.

[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


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




Bloc+< call



B lock end

Block end

Bloc k en d

Fi\l:"'" 17.1 MCR Arc. in the Case "f Block Change


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-



FBD rep' .... nt-'Ion '


, 1.1




---l ---l


S"';Id:.ing QD ),liCk dopoJODCY III

MCR."""" I and Mt:R...-2

~1 .;

'I':' .rl< 2} 'ifMC"!hpn" ,.. , "t',


I ..

(MCR<H :

(MCR z_1J
t 1.1


S"'i<chi"" "fMC,,,
.wi t, ~e<I


0 0

ill MeR ;:QIl' 2 ooly if MCR

deponden<:y in MCR rorlO T il




{J..teR zone



(MCR>H ,:

! MCR~ !


17.4 'ktlin& and R..~cuin& UO B;I>I


[MeR zone '1

[MCR zone I I

F-{.''"<f-{\ M 10.0 --i

[MeR zone 1]





zone 2J

BlOCk call



" 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


!>OO MCR dep..--n<knr;y Nn MCR dc-pendenC)' MeR dependoonc)' enabled

MCI!. depeodency """bled

17 MasterCODlml Relay


17.2 ParamctCT< of the SFC. fo' Controlling the 1/0 Hi" P"""ncter

Decl ..... tion

D.ta Type
~ ,












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


lAO rapr. .en !.lOtion

C.11InK on f8 or SFH whh d... bl""k a. 1"".1 instanU


Callin/( an Fe M STC with CALI. t><>. with CALL ooil

HI...... nd

["'ponde"t on RJ.n



IN' - '"

-- 'N OUlI -- IN'





--{ RET}----i








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





o.."p<"do,,! on RLO




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>

[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


hlins the


cominucs proccssiull this


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 '

\"1 _ 0

... --,
"ro<~,sin!l. oj"blod 1"''''mOl.... CO'ro!sIJQ",h ' ,,, p1W~,,;n/( of Ih. ~cl""ll'/zr;abl~., durinj{ "'"""'~


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~


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

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




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~


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:


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.


18.1 Block Funelions for Cotk Blocks

~ -.:, -:::J[==l~::-::.::. :j:;.;-~_""C=;- ~=.:~{:-~'-;'-..'.'.~ . =-~':~

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

.. ......

.. _


.. _

,- -..


..... " ' -

~. -


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 f