1.PROGRAMMABLELOGICCONTROLLERS1.1INTRODUCTIONControlengineeringhasevolvedovertime.Inthepasthumanswasthemainmethodforcontrollingasystem.Morerecentlyelectricityhasbeenusedforcontrolandearlyelectricalcontrolwasbasedonrelays.Theserelaysallowpowertobeswitchedonandoffwithoutamechanicalswitch.Itiscommontouserelaystomakesimplelogicalcontroldecisions.Thedevelopmentoflowcostcomputerhasbroughtthemostrecentrevolution,theProgrammableLogicController(PLC).TheadventofthePLCbeganinthe1970s,andhasbecomethemostcommonchoiceformanufacturingcontrols.PLChavebeengainingpopularityonthefactoryfloorandwillprobablyremainpredominantforsometimetocome.Mostofthisisbecauseoftheadvantagestheyoffer..Costeffectiveforcontrollingcomplexsystems..Flexibleandcanbereappliedtocontrolothersystemsquicklyandeasily..Computationalabilitiesallowmoresophisticatedcontrol..Troubleshootingaidsmakeprogrammingeasierandreducedowntime..Reliablecomponentsmaketheselikelytooperateforyearsbeforefailure.1.2LadderLogicLadderlogicisthemainprogrammingmethodusedforPLC.Asmentionedbefore,ladderlogichasbeendevelopedtomimicrelaylogic.Thedecisiontousetherelaylogicdiagramswasastrategicone.Byselectingladderlogicasthemainprogrammingmethod,theamountofretrainingneededforengineersandtradespeoplewasgreatlyreduced.Moderncontrolsystemsstillincluderelays,butthesearerarelyusedforlogic.Arelayisasimpledevicethatusesamagneticfieldtocontrolaswitch,aspicturedinFigure2.1.Whenavoltageisappliedtotheinputcoil,theresultingcurrentcreatesamagneticfield.Themagneticfieldpullsametalswitch(orreed)towardsitandthecontactstouch,closingtheswitch.Thecontactthatcloseswhenthecoilisenergizediscallednormallyopen.Thenormallyclosedcontactstouchwhentheinputcoilisnotenergized.Relaysarenormallydrawninschematicformusingacircletorepresenttheinputcoil.Theoutputcontactsareshownwithtwoparallellines.Normallyopencontactsareshownastwolines,andwillbeopen(non-conducting)whentheinputisnotenergized.Normallyclosedcontactsareshownwithtwolineswithadiagonallinethroughthem.Whentheinputcoilisnotenergizedthenormallyclosedcontactswillbeclosed(conducting).Relaysareusedtoletonepowersourcecloseaswitchforanother(oftenhighcurrent)powersource,whilekeepingthemisolated.AnexampleofarelayinasimplecontrolapplicationisshowninFigure2.2.Inthissystemthefirstrelayontheleftisusedasnormallyclosed,andwillallowcurrenttoflowuntilavoltageisappliedtotheinputA.ThesecondrelayisnormallyopenandwillnotallowcurrenttoflowuntilavoltageisappliedtotheinputB.Ifcurrentisflowingthroughthefirsttworelaysthencurrentwillflowthroughthecoilinthethirdrelay,andclosetheswitchforoutputC.Thiscircuitwouldnormallybedrawnintheladderlogicform.ThiscanbereadlogicallyasCwillbeonifAisoffandBison.1.3ProgrammingThefirstPLCwereprogrammedwithatechniquethatwasbasedonrelaylogicwiringschematics.Thiseliminatedtheneedtoteachtheelectricians,techniciansandengineershowtoprogramacomputer-but,thismethodhasstuckanditisthemostcommontechniqueforprogrammingPLCtoday.AnexampleofladderlogiccanbeseeninFigure2.5.Tointerpretthisdiagramimaginesthatthepowerisontheverticallineonthelefthandside,wecallthisthehotrail.Ontherighthandsideistheneutralrail.Inthefiguretherearetworungs,andoneachrungtherearecombinationsofinputs(twoverticallines)andoutputs(circles).Iftheinputsareopenedorclosedintherightcombinationthepowercanflowfromthehotrail,throughtheinputs,topowertheoutputs,andfinallytotheneutralrail.Aninputcancomefromasensor,switch,oranyothertypeofsensor.AnoutputwillbesomedeviceoutsidethePLCthatisswitchedonoroff,suchaslightsormotors.Inthetoprungthecontactsarenormallyopenandnormallyclosed,whichmeansifinputAisonandinputBisoff,thenpowerwillflowthroughtheoutputandactivateit.AnyothercombinationofinputvalueswillresultintheoutputXbeingoff.ThesecondrungofFigure2.5ismorecomplex,thereareactuallymultiplecombinationsofinputsthatwillresultintheoutputYturningon.Ontheleftmostpartoftherung,powercouldflowthroughthetopifCisoffandDison.Powercouldalso(andsimultaneously)flowthroughthebottomifbothEandFaretrue.Thiswouldgetpowerhalfwayacrosstherung,andthenifGorHistruethepowerwillbedeliveredtooutputY.Inlaterchapterswewillexaminehowtointerpretandconstructthesediagrams.ThereareothermethodsforprogrammingPLC.Oneoftheearliesttechniquesinvolvedmnemonicinstructions.TheseinstructionscanbederiveddirectlyfromtheladderlogicdiagramsandenteredintothePLCthroughasimpleprogrammingterminal.AnexampleofmnemonicsisshowninFigure2.6.Inthisexampletheinstructionsarereadonelineatatimefromtoptobottom.Thefirstline00000hastheinstructionLDN(inputloadandnot)forinput00001.ThiswillexaminetheinputtothePLCandifitisoffitwillremembera1(ortrue),ifitisonitwillremembera0(orfalse).ThenextlineusesanLD(inputload)statementtolookattheinput.Iftheinputisoffitremembersa0,iftheinputisonitremembersa1(note:thisisthereverseoftheLD).TheANDstatementrecallsthelasttwonumbersrememberedandiftheyarebothtruetheresultisa1;otherwisetheresultisa0.Thisresultnowreplacesthetwonumbersthatwererecalled,andthereisonlyonenumberremembered.Theprocessisrepeatedforlines00003and00004,butwhenthesearedonetherearenowthreenumb