Jürgen Kaftan PLC Basic Course with SIMATIC S7 Jürgen Kaftan PLC Basic Course with SIMATIC S7 Structure and Function of Programmable Logic Controllers, Programming with the SIMATIC S7 First Edition JürgenKaftan 1967-1971 Apprenticeshipasanelectrician 1971-1973 Skilledtradesmaninthetradeofelectrician 1973-1975 Trainingasastate-certifiedelectricalengineer 1975-1977 Employedasatechnician 1977-1978 Schoolformastercraftsmen,graduatedasmasterelectrician 1979-1992 Nurembergvocationaltrainingcentreforhearingand speechimpairedpersons,MasterTrainer 1985-1992 CourseLeaderforPLCsinvocationaltraining(BFH)forhearing andspeechimpairedpersons 1985-1992 CourseLeaderforPLCsattheChamberofCrafts 1992-1995 IKHElektrogerätebau–SystemTrainingCourses (ManagingDirector) Since1995 ManagerofIHKSystemschulungenforHardwareandSoftware (ChamberofIndustryandCommercehardwareandsoftware systemtrainingcourses)inWeißenburgandRoth (CentralFranconia) JürgenKaftanistheauthorofthefollowingreferencebookspublishedbyVogel: PLCBasicCourse1 PLCBasicCourse2 PLCBasicCoursewithSIMATICS7 ThebookincludesaSiemensAGdemonstrationCD-ROM»STEP7Professional,Edition2004 SR4,TrialLicense«including:STEP7V5.3SP3,S7-GRAPHV5.3SP2,S7-SCLV5.3SP1,S7- PLCSIMV5.3SP1andcanbeusedfortestpurposesfor14days. ThesoftwareonlyrunsunderWindows2000ProfessionalSP4andaboveorWindowsXPPro- fessionalSP1andabove. ForfurtherinformationontheInternet,visit www.siemens.de/sce/promotoren. Furtherinformation: www.vogel-buchverlag.de ISBN978-3-8343-3201-1 FirstEdition2011 Allrightsreservedincludingtranslation.Nopartofthisworkmaybe reproduced,processedusinganytypeofelectronicsystem,duplicated ortransmittedinanywayorinanyform(printing,photocopying,mi- crofilmorusinganyotherprocess)withouttheexpresswrittencon- sentofthepublisher.TheexceptionsstatedexpresslyinPara.53,54of theGermanCopyrightActarenotaffected. PrintedinGermany Copyright1998byVogelIndustrieMedienGmbH&Co.KG, Würzburg Bookjacketillustration:MichaelM.Kappenstein,Frankfurt Foreword Programmablelogiccontrollers,knownforshortasPLCs,areanintegralpartof automation at the lower, middle and upper performance levels. Due to the ever increasingsizeandcomplexityofthehardwareandsoftwarerequiredinautoma- tion projects, the industry has had to develop faster, more capable and effective automation systems and to simplify handling for users. All the exercises in this book have been developed and tested using Siemens' SIMATIC S7-300 PLC.The command set of this controller ranges from binary processing to 32-bit floating pointarithmetic.ThecontrollerisprogrammedundertheWindowsXPoperating system and it is assumed that users have an appropriate basic knowledge.All the procedures for programming the SIMATIC S7-300 are demonstrated exactly and are easy to understand for users.The topic builds up from "easy to hard" and is ideally suited for use in vocational and technical training colleges,etc.as well as foruseonateach-yourselfbasis. IwouldliketothanktheWükro-LehrsystemecompanyinWürzburgaswellas everybodywhohashelpedinthecompletionofthisbook.Iamalwaysgratefulto receivefeedbackfromreadersandusers. Weißenburg/Heuberg(CentralFranconia) JürgenKaftan 5 6 Contents Foreword....................................................................................................... 5 1 Introduction.................................................................................... 13 1.1 Numbersystem............................................................................... 13 1.2.2 Byte................................................................................................. 14 1.2.3 Word............................................................................................... 14 1.2 Termsfromcomputerscience.......................................................... 14 1.2.1 Bit................................................................................................... 14 1.2.4 Bitaddress....................................................................................... 15 1.2.5 Byteaddress.................................................................................... 15 1.2.6 Wordaddress.................................................................................. 15 2 ArrangementofaPLC..................................................................... 17 2.1 StructureofaPLC........................................................................... 18 2.2 Structureofanautomationunit...................................................... 18 2.3 Hardwarerequirements................................................................... 18 2.3.1 Hardwarestructure......................................................................... 20 2.4 Softwarerequirements..................................................................... 20 2.4.1 STEP7programminglanguage....................................................... 20 2.4.2 Objects............................................................................................ 20 2.4.3 Projects........................................................................................... 21 2.4.4 ConfiguringanS7-300.................................................................... 22 2.4.5 Parameterization............................................................................. 22 3 WayofFunctioningofaPLC.......................................................... 23 3.1 ModulesofthePLC........................................................................ 23 3.1.1 Powersupplyunit........................................................................... 23 3.1.2 Programmemory............................................................................ 24 3.1.3 Centralprocessingunit(CPU)......................................................... 25 3.1.4 Bussystem....................................................................................... 27 3.1.5 Inputandoutputmodules............................................................... 27 4 ProgramProcessingandProgramming............................................ 29 4.1 Linearprogramprocessing.............................................................. 29 4.2 Structuredprogramming................................................................. 30 4.3 Controlinstruction.......................................................................... 31 4.3.1 Operationpart................................................................................ 32 7 4.3.2 Examplesfordigitaloperations....................................................... 32 4.3.3 Examplesofbinaryoperations........................................................ 32 4.3.4 Examplesoforganizationaloperations............................................ 33 4.3.5 Operandpart.................................................................................. 33 4.4 Addressing...................................................................................... 34 4.4.1 SymbolicAddressing....................................................................... 34 4.4.2 Absoluteaddressing........................................................................ 34 4.4.3 Immediateaddressing...................................................................... 34 4.4.3.1 Directaddressing............................................................................. 34 4.4.3.2 Memory-indirectaddressing............................................................ 35 4.5 Programrepresentation................................................................... 35 4.5.1 Ladderdiagram(LAD).................................................................... 36 4.5.2 FunctionblockdiagramFBD(STEP7V3.xandabove).................. 36 4.5.3 StatementlistSTL........................................................................... 36 4.6 Flags................................................................................................ 37 4.6.1 Retentiveflags................................................................................. 37 4.6.2 Non-retentiveflags.......................................................................... 38 5 Logicoperations.............................................................................. 39 5.1 Basiclogicoperations...................................................................... 39 5.1.1 ClearingtheCPU............................................................................ 40 5.1.2 Creatingprojects............................................................................. 42 5.1.3 InsertingtheSIMATIC300station.................................................. 43 5.1.4 Configuringandparameterizing...................................................... 43 5.1.5 Arrangementofthepowersupply................................................... 45 5.1.6 ArrangementoftheCPU314.......................................................... 46 5.1.7 Arrangementoftheinputmodule................................................... 46 5.1.8 Arrangementoftheoutputmodule................................................. 47 5.1.9 ParameterizingtheCPU314........................................................... 47 5.1.10 Savingtheglobalconfiguration....................................................... 49 5.1.11 TransferringtheconfigurationtotheCPU...................................... 49 5.2 LogicalANDoperationuserprogram............................................. 50 5.2.1 EnteringFCs(FC1)........................................................................ 50 5.2.2 S7blockfunction............................................................................ 52 5.2.3 EnteringOB1................................................................................. 55 5.2.4 Downloading.................................................................................. 58 5.2.5 Testing............................................................................................. 59 5.2.6 Specifyingtriggerconditions........................................................... 60 5.2.7 DeactivatingtheFBDprogramstatus.............................................. 63 5.2.8 TestingwithSTL............................................................................. 63 5.2.9 TestingwithLAD............................................................................ 65 5.2.10 Extendingfromtwotothreeinputs(3rd.inputI0.2)....................... 67 5.2.10.1ExtendingwithSTL........................................................................ 67 8 5.2.10.2ExtendingwithLAD....................................................................... 69 5.2.10.3ExtendingwithFBD........................................................................ 71 5.2.11 Reducingfrom3inputsto2(deleteI0.2)........................................ 73 5.2.11.1ReducingwithSTL.......................................................................... 73 5.2.11.2ReducingwithLAD........................................................................ 74 5.2.11.3ReducingwithFBD......................................................................... 74 5.3 LogicalORoperationuserprogram................................................ 75 5.3.1 EnteringtheprogramusingthePC(FBD)....................................... 75 5.3.2 Createtheproject............................................................................ 76 5.3.3 CopySIMATICstation1intoanotherproject................................. 77 5.3.4 ChangeOB1................................................................................... 80 5.3.5 Downloading.................................................................................. 82 5.3.6 Testing............................................................................................. 82 6 ProgramInput................................................................................. 85 6.1 ANDbeforeOR.............................................................................. 85 6.2 ORbeforeAND.............................................................................. 88 6.3 Pollforsignalstate0....................................................................... 91 6.4 ExclusiveORoperation.................................................................. 94 6.5 Pollingoutputs................................................................................ 96 6.6 Insertingnetworks........................................................................... 98 6.7 LatchcircuitwiththePC................................................................. 101 6.8 PracticalexamplesofcontrolwiththePC....................................... 105 6.8.1 Temperaturedifference.................................................................... 105 6.8.2 Drinksmachine............................................................................... 106 6.8.3 Intercom.......................................................................................... 108 6.8.4 Generator........................................................................................ 110 6.8.5 Boilercontrol.................................................................................. 112 6.8.6 Smeltingfurnaces............................................................................ 113 6.9 Flip-flop.......................................................................................... 116 6.9.1 R-Sflip-flop..................................................................................... 116 6.9.2 Enteringtheprogram...................................................................... 118 6.9.3 Pumpcontroller.............................................................................. 122 7 CreatingMomentaryImpulses(EdgeInstructions).......................... 127 7.1 Momentaryimpulsewitharisingedge(FP).................................... 127 7.2 Momentaryimpulsewithafallingedge(FN).................................. 128 7.3 Programinput................................................................................. 128 7.4 Acknowledgementcircuit................................................................ 132 8 TimingFunctions............................................................................ 135 8.1 Timingvaluespecification............................................................... 135 8.2 Releaseatime(FR)......................................................................... 136 8.3 Currentvalue.................................................................................. 136 9 8.4 Resettime....................................................................................... 137 8.5 Selectionoftimes(fivedifferentones)............................................. 137 8.5.1 Pulsetimer(SP)............................................................................... 137 8.5.2 Extendedpulsetimer(SE)............................................................... 139 8.5.3 Switch-ondelaytimer(SD).............................................................. 140 8.5.4 Retentiveswitch-ondelaytimer(SS)............................................... 142 8.5.5 Switch-offdelaytimer(SF).............................................................. 143 8.6 PCprograminputoftimingfunctions............................................. 144 8.6.1 Garagelighting................................................................................ 147 8.6.2 Fillingsystem.................................................................................. 149 8.6.3 Compressorsystem......................................................................... 150 9 ClockGenerators............................................................................ 153 9.1 PCprograminputwithclockgenerator.......................................... 154 9.1.1 Channelswitch................................................................................ 156 9.1.2 Pagingsystem.................................................................................. 157 9.1.3 Airsupply....................................................................................... 159 10 Counters......................................................................................... 163 10.1 Loadandtransferfunctions............................................................ 163 10.2 Counterfunctions........................................................................... 164 10.2.1 Releaseacounter(FR).................................................................... 164 10.2.2 Countingforwards.......................................................................... 164 10.2.3 Countingbackwards....................................................................... 164 10.2.4 Setcounter...................................................................................... 165 10.2.5 Countvaluedefinition..................................................................... 165 10.2.6 Resetcounter(R)............................................................................ 165 10.2.7 Pollcountvalue(L/LC)................................................................... 165 10.2.8 Pollsignalstateofcounter(binary)................................................. 166 10.3 PCprograminputcleaningbath...................................................... 167 11 Comparators................................................................................... 169 11.1 Comparisonfunctions..................................................................... 169 11.1.1 Equalto==.................................................................................... 169 11.1.2 Notequal<>................................................................................... 170 11.1.3 Greaterthanequalto>=................................................................. 170 11.1.4 Greaterthan>................................................................................. 170 11.1.5 Lessthanequalto<=...................................................................... 170 11.1.6 Lessthan<...................................................................................... 171 11.2 PCprograminputrunwaylight....................................................... 171 11.3 Programinputsequencefunction.................................................... 174 12 PracticalExampleswithSimulators................................................. 177 12.1 Seven-segmentdisplay..................................................................... 177 12.2 Star-deltastarting............................................................................ 179 10
Description: