ladder diagram instructions

Upload: 03sri03

Post on 02-Nov-2015

215 views

Category:

Documents


0 download

DESCRIPTION

Ladder diagram

TRANSCRIPT

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 1/17

    IntroductiontoPLCcontrollersonlineFREE!

    IndexDevelopmentsystemsContactus

    Previouspage Tableofcontents NextPage

    APPENDIXELadderdiagraminstructions(1/3)

    Introduction

    "Ladder"isthemostfrequentmethodofprogrammingPLCcontrollersatpresent.Wecoulddivideinstructionsontheinputonesforstatingtheconditionsandtheoutputonesthatareexecutedwhentheconditionsarefulfilled.Bycombiningthetwo,logicalblocksarecreatedaccordingtothelogicofthesystembeingautomated.Thepurposeofthisappendixistointroducetheseinstructionsandtogivedetailsonflagsandlimitationsofeachofthese.

    INDIRECTADDRESSING

    Placingthecharacter*aheadofoperandfromDMmemoryareaallowsustousetheindirectaddressing.Simplyput,valueintheword*DMwillbetheaddressofthewordthatisthetrueoperand.ThepicturebelowshowstheMOVinstructionwithoneoperandgivenindirectly.ThecontentsoflocationDM0003equal1433whichisactuallyapointermarkingtheaddressDM1433withcontents0005.Theresultofthisinstructionwillbemovingthevalue0005fromwordDM1433towordLR00.

    Inordertousetheindirectaddressing,contentsofthewordthatistheindirectoperandhavetobeinBCDformat.Besidesthat,valueofthecontentsofindirectoperandmustnotbegreaterthanthenumberofaddressesinDMarea.

    INSTRUCTIONFORMAT

    OperandistheaddressofawordorabitinPLCcontrollermemory(mostoftheinstructionshasoneormoreoperands).Thecommontermforawordisjustoperandandinthecaseofbitwecallitoperandbit.Also,operandcanbeadirectnumericalvaluemarkedbycharacter#placedaheadofthevalue(i.e..#12,#345etc).

    ThestateofoperandbitcanbeONorOFF.ONmeansthatitslogicstateequals1,whileOFFstandsfor0.Besidesthese,termssetandresetarealsoused.

    SymbolsSVandPVcommonlyappearininstructionsyntax.TheseabbreviationsstandforSetValueandPresentValueandaremostfrequentlyencounteredwithinstructionsconcerningcountersandtimers.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 2/17

    DIFFERENTIALINSTRUCTIONFORM

    Differentialformissupportedbyalmostalloftheinstructions.Whatdiffersthisformfromtheclassicaloneisthecharacter@placedaheadofthenameoftheinstruction.Thisformensuresthattheinstructionwithconditionfulfilledwillnotbeexecutedineverycycle,butonlywhenitsconditionchangesstatefromOFFtoON.Differentialfromiscommonlyusedbecauseithasalotofapplicationsinreallifeproblems.

    DIFFERENCEBETWEENBINARYANDBCDREPRESENTATIONSOFWORDCONTENTS

    Generally,therearetwodominantwaysforcomprehendingvaluesofmemorylocations.Thefirstisbinaryandisrelatedtothecontentsofthewordwhichistreatedasaunionof16bits.Valueiscalculatedasasumofeachbit(0or1)multipliedby2onpowern,wherenrepresentsthepositionofbitintheword.Bitoftheleastvaluehaspositionzero,whilebitofgreatestvaluehasposition15.

    BCDisanabbreviationforBinaryCodedDecimalnumber.Itisnothingmorethanrepresentingeachdecimalfigurewith4bits,similartobinarycodinghencethenamecomesfrom.ThepicturebelowshowsthedifferencebetweenbinaryandBCDrepresentationsofthenumber.Samecontentscanbeinterpretedaseither612or264.Forthatreason,properattentionshouldbegiventotheformatofthevaluewithinthewordthatwillbesenttotheinstructionasanoperand.

    LADDERDIAGRAMINSTRUCTIONS

    Instructionsmaybedividedintoseveralbasicgroupsaccordingtotheirpurpose:

    InputinstructionsOutputinstructionsControlinstructionsTimer/counterinstructionsDatacomparisoninstructionsDatamovementinstructionsIncrement/decrementinstructionsBCD/binarycalculationinstructionsDataconversioninstructionsLogicinstructionsSpecialcalculationinstructionsSubroutineinstructionsInterruptcontrolinstructions

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 3/17

    I/OunitsinstructionsDisplayinstructionsHighspeedcountercontrolinstructionsDamagediagnosisinstructionsSpecialsysteminstructions

    Eachoftheseinstructiongroupsisintroducedwithabriefdescriptioninthefollowingtablesandwithmoredetailedexamplesanddescriptionsafterwards.

    SequenceInputInstructions

    Instruction Mnemonic Code FunctionLOAD LD 0 ConnectsanNOconditiontotheleftbusbar.

    LOADNOT LDNOT 0 ConnectsanNCconditiontotheleftbusbar.

    AND AND 0 Connects an NO condition in series with the previouscondition

    ANDNOT ANDNOT 0 Connects an NC condition in series with the previouscondition

    OR OR 0 Connects an NO condition in parallel with the previouscondition.

    ORNOT ORNOT 0 Connects an NC condition in parallel with the previouscondition.ANDLOAD ANDLD 0 Connectstwoinstructionblocksinseries.

    ORLOAD ORLD 0 Connectstwoinstructionblocksinparallel.

    SequenceOutputInstructions

    Instruction Mnemonic Code FunctionOUTPUT OUT 0 Outputstheresultoflogictoabit.OUTNOT OUTNOT 0 Reversesandoutputstheresultoflogictoabit.SET SET 0 Forcesets(ON)abit.RESET RESET 0 Forceresets(OFF)abit.KEEP KEEP 11 Maintainsthestatusofthedesignatedbit.DIFFERENTIATEUP DIFU 13

    Turns ON a bit for one cycle when the executionconditiongoesfromOFFtoON.

    DIFFERENTIATEDOWN DIFD 14

    Turns ON a bit for one cycle when the executionconditiongoesfromONtoOFF.

    SequenceControlInstructions

    Instruction Mnemonic Code Function

    NOOPERATION NOP 00

    END END 01 Requiredattheendoftheprogram.

    INTERLOCK IL 02It theexecutioncondition for IL(02) isOFF,all outputsare turnedOFFandall timer PVs reset between IL(02)andthenextILC(03).

    INTERLOCKCLEAR ILC 03

    ILC(03) indicates the end of an interlock (beginning atIL(02)).

    JUMP JMP 04If the execution condition for JMP(04) is ON, allinstructions between JMP(04) and JME(05) are treatedasNOP(OO).

    JUMPEND JME 05 JME(05) indicates the end of a jump (beginning atJMP(04)).

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 4/17

    Timer/CounterInstructions

    Instruction Mnemonic Code FunctionTIMER TIM 0 AnONdelay(decrementing)timer.

    COUNTER CNT 0 Adecrementingcounter.

    REVERSIBLECOUNTER CNTR 12 IncreasesordecreasesPVbyone.

    HIGHSPEEDTIMER TIMH 15 Ahighspeed,ONdelay(decrementing)timer.

    DataComparisonInstructions

    Instruction Mnemonic Code Function

    COMPARE CMP 20 Comparestwofourdigithexadecimalvalues.

    DOUBLECOMPARE CMPL 60 Comparestwoeightdigithexadecimalvalues.

    BLOCKCOMPARE (@)BCMP 68 Judgeswhetherthevalueofawordiswithin16ranges(definedbylowerandupperlimits).

    TABLECOMPARE (@)TCMP 85 Comparesthevalueofawordto16consecutivewords.

    DataMovementInstructions

    Instruction Mnemonic Code Function

    MOVE (@)MOV 21 Copiesaconstantorthecontentofawordtoaword.

    MOVENOT (@)MVN 22 Copiesthecomplementofaconstantorthecontentofawordtoaword.BLOCKTRANSFER (@)XFER 70

    Copiesthecontentofablockofupto1,000consecutivewordstoablockofconsecutivewords.

    BLOCKSET (@)BSET 71 Copies thecontentofaword toablockof consecutivewords.

    DATAEXCHAGE (@)XCHG 73 Exchangesthecontentoftwowords.

    SINGLEWORDDISTRIBUTE (@)DIST 80

    Copiesthecontentofawordtoaword(whoseaddressisdeterminedbyaddinganoffsettoawordaddress).

    DATACOLLECT (@)COLL 81Copies the content of a word (whose address isdeterminedbyaddinganoffsettoawordaddress)toaword.

    MOVEBIT (@)MOVB 82 Copies the specifiedbit fromoneword to the specifiedbitofaword.

    MOVEDIGIT (@)MOVD 83 Copies the specifieddigits (4bitunits) fromaword tothespecifieddigitsofaword.

    ShiftInstructions

    Instruction Mnemonic Code Function

    SHIFTREGISTER SFT 0/10

    Copiesthespecifiedbit(0or1)intotherightmostbitofa shift register and shifts the other bits one bit to theleft.

    WORDSHIFT (@)WSFT 16 Createsamultiplewordshiftregisterthatshiftsdatatotheleftinonewordunits.

    ASYNCHRONOUSSHIFTREGISTER (@)ASFT 17

    Creates a shift register that exchanges the contentsofadjacentwordswhenoneiszeroandtheotherisnot.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 5/17

    ARITHMETICSHIFTLEFT

    (@)ASL 25 Shiftsa0intobit00ofthespecifiedwordandshiftstheotherbitsonebittotheleft.

    ARITHMETICSHIFTRIGHT (@)ASR 26

    Shiftsa0intobit15ofthespecifiedwordandshiftstheotherbitsonebittotheright.

    ROTATELEFT (@)ROL 27Moves the content of CY into bit 00 of the specifiedword,shiftstheotherbitsonebittotheleft,andmovesbit15toCY.

    ROTATERIGHT (@)ROR 28Moves the content of CY into bit 15 of the specifiedword,shiftstheotherbitsonebittotheleft,andmovesbit00toCY.

    ONEDIGITSHIFTLEFT (@)SLD 74

    Shiftsa0intotherightmostdigit(4bitunit)oftheshiftregisterandshiftstheotherdigitsonedigittotheleft.

    ONEDIGITSHIFTRIGHT (@)SRD 75

    Shiftsa0intotherightmostdigit(4bitunit)oftheshiftregisterandshiftstheotherdigitsonedigittotheright.

    REVERSIBLESHIFTREGISTER (@)SFTR 84

    Createsasingleormultiplewordshiftregisterthatcanshiftdatatotheleftorright.

    Increment/DecrementInstructions

    Instruction Mnemonic Code FunctionINCREMENT (@)INC 38 IncrementstheBCDcontentofthespecifiedwordby1.DECREMENT (@)DEC 39 DecrementstheBCDcontentofthespecifiedwordby1.

    BCD/BinaryCalculationInstructions

    Instruction Mnemonic Code FunctionBCDADD (@)ADD 30 Addsthecontentofaword(oraconstant).

    BCDSUBTRACT (@)SUB 31 Subtracts the contents of aword (or constant) andCYfromthecontentofaword(orconstant).BDCMULTIPLY (@)MUL 32 Multipliesthecontentoftwowords(orcontents).

    BCDDIVIDE (@)DIV 33 Divides the contents of a word (or constant) by thecontentofaword(orconstant).BINARYADD (@)ADB 50 Addsthecontentsoftwowords(orconstants)andCY.BINARYSUBTRACT (@)SBB 51

    Subtracts the content of a word (or constant) an CYfromthecontentoftheword(orconstant).

    BINARYMULTIPLY ()MLB 52 Multipliesthecontentsoftwowords(orconstants).

    BINARYDIVIDE (@)DVB 53 Divides the content of a word (or constant) by thecontentofawordandobtainstheresultandremainder.DOUBLEBCDADD (@)ADDL 54

    Add the8digitBCDcontentsof twopairsofwords(orconstants)andCY.

    DOUBLEBCDSUBTRACT (@)SUBL 55

    Subtractsthe8digitBCDcontentsofapairofwords(orconstants)andCYfromthe80digitBCDcontentsofapairofwords(orconstants)

    DOUBLEBCDMULITPLY (@)MULL 56

    Multipliesthe8digitBCDcontentsoftwopairsofwords(orconstants).

    DOUBLEBCDDIVIDE (@)DIVL 57

    Divides the8digitBCDcontentsofapairofwords (orconstants) by the 8digits BCD contents of a pair ofwords(orconstants)

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 6/17

    DataConversionInstructions

    Instruction Mnemonic Code FunctionBCDTOBINARY (@)BIN 23 Converts4digitBCDdatato4digitbinarydata.

    BINARYTOBCD (@)BCD 24 Converts4digitbinarydatato4digitBCDdata.4to16DECODER (@)MLPX 76

    Takesthehexadecimalvalueofthespecifieddigit(s)inawordandturnONthecorrespondingbitinaword(s).

    16to4DECODER (@)DPMX 77

    Identifies the highest ON bit in the specified word(s)and moves the hexadecimal value(s) corresponding toitslocationtothespecifieddigit(s)inaword.

    ASCIICODECONVERT (@)ASC 86

    Converts the designated digit(s) of a word into theequivalent8bitASCIIcode.

    LogicInstructions

    Instruction Mnemonic Code Function

    COMPLEMENT (@)COM 29 TurnsOFFallONbits and turnsONallOFFbits in thespecifiedword

    LOGICALAND (@)ANDW 34 Logically ANDs the corresponding bits of two word (orconstants)

    LOGICALOR (@)ORW 35 Logically ORs the corresponding bits of two word (orconstants)

    EXCLUSIVEOR (@)XORW 36 ExclusivelyORsthecorrespondingbitsoftwowords (orconstants)

    EXCLUSIVENOR (@)XNRW 37 Exclusively NORs the corresponding bits of two words(orconstants).

    SpecialCalculationInstructions

    Instruction Mnemonic Code Function

    BITCOUNTER (@)BCNT 67 CountsthetotalnumberofbitsthatareONinthespecifiedblock

    SubroutineInstructions

    Instruction Mnemonic Code FunctionSUBROUTINEENTER (@)SBS 91 Executesasubroutineinthemainprogram.

    SUBROUTINEENTRY SBN 92 Marksthebeginningofasubroutineprogram.

    SUBROUTINERETURN RET 93 Markstheendofasubroutineprogram.

    MACRO MACRO 99Callsandexecutesthespecifiedsubroutine,substitutingthe specified input and outputwords for the input andoutputwordsinthesubroutine.

    InterruptControlInstructions

    Instruction Mnemonic Code Function

    INTERVALTIMER (@)STIM 69 Controls interval timers used to perform scheduledinterrupts.INTERRUPTCONTROL (@)INT 89

    Performs interrupts control, such as masking andunmaskingtheinterruptbitsforI/Ointerrupts.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 7/17

    StepInstructions

    Instruction Mnemonic Code Function

    STEPDEFINE STEP 08Definesthestartofanewstepandresetsthepreviousstep when used with a control bit. Defines the end ofstepexecutionwhenusedwithoutacontrolbit.

    STEPSTART SNXT 09 Startstheexecutionofthestepwhenusedwithacontrolbit.

    PeripheralDeviceControlInstructions

    Instruction Mnemonic Code FunctionBCDTOBINARY (@)BIN 23 Converts4digitBCDdatato4digitbinarydata.

    BINARYTOBCD (@)BCD 24 Converts4digitbinarydatato4digitBCDdata.4to16DECODER (@)MLPX 76

    Takesthehexadecimalvalueofthespecifieddigit(s)inawordandturnONthecorrespondingbitinaword(s).

    16to4DECODER (@)DPMX 77

    Identifies the highest ON bit in the specified word(s)and moves the hexadecimal value(s) corresponding toitslocationtothespecifieddigit(s)inaword.

    ASCIICODECONVERT (@)ASC 86

    Converts the designated digit(s) of a word into theequivalent8bitASCIIcode.

    I/OUnitsInstructions

    Instruction Mnemonic Code Function7SEGMENTDECODER (@)SDEC 78

    Convertsthedesignateddigit(s)ofawordintoan8bit,7segmentdisplaycode.

    I/OREFRESH (@)IORF 97 RefreshesthespecifiedI/Oword.

    DisplayInstructions

    Instruction Mnemonic Code FunctionMEASSAGE (@)MSG 46 Readsupto8wordsofASCIIcode(16characters)from

    memoryanddisplaysthemessageontheProgrammingConsoleorotherPeripheralDevice.

    HighSpeedCounterControlInstructions

    Instruction Mnemonic Code FunctionMODECONTROL (@)INI 61

    Startsandstopscounteroperation,comparesandchangescounterPVs,andstopspulseoutput.

    PVREAD (@)PRV 62 ReadscounterPVsandstatusdata.COMPARETABLELOAD (@)CTBL 63

    ComparescounterPVsandgeneratesadirecttableorstartsoperation.

    DamageDiagnosisInstructions

    Instruction Mnemonic Code FunctionGeneratesanonfatalerrorwhenexecuted.The

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 8/17

    FAILUREALARM (@)FAL 06 Error/AlarmindicatorflashesandtheCPUcontinuesoperating.

    SEVEREFAILUREALARM FAL 07

    Generatesafatalerrorwhenexecuted.TheError/AlarmindicatorlightsandtheCPUstopsoperating.

    SpecialSystemInstructions

    Instruction Mnemonic Code FunctionSETCARRY (@)STC 40 SetsCarryFlag25504to1.CLEARCARRY (@)CLC 41 SetsCarryFlag25504to0.

    E.1LOADNormallyopenoutput

    Description Firstcondition,thatanylogicalblockintheladderdiagramstartswith,correspondstoLOADorLOADNOTinstructions.Bothoftheseinstructionsrequireonelineinmnemoniccode.Ontherightoftheseinstructionsanyexecutiveinstructionmaybeused.

    Laddersymbol

    Limitations Therearenolimitations,exceptthatitisusedasthefirstinstructionfromlefttoright.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    Pressingthebuttonontheinput00inthewordIR000activatestherelay00ontheoutputofPLCcontroller.Conditionalinstructiondoesnthavebefrominputmemoryareaitcanbeanybitfromothermemoryareas,i.e.SRareaasinthefollowingexample.

    Whenoneoftheinstructionsactivatesthebit00inthewordSR200,bit00isactivatedintheoutputwordIR010.Inaword,everyONstateofthebitatinputcausestheONstateatoutput.

    E.2LOADNOTNormallyclosedinput

    Description Firstcondition,thatanylogicalblockintheladderdiagramstartswith,correspondstoLOADorLOADNOTinstructions.Bothoftheseinstructionsrequireonelineinmnemoniccode.Ontherightoftheseinstructionsanyexecutiveinstructionmaybeused.

    Laddersymbol

    Limitations Therearenolimitations,exceptthatitisusedasthefirstinstructionfromlefttoright.

    Flag Ithasnoeffectonanyparticularflag.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 9/17

    Example

    Pressingthebuttonontheinput00inthewordIR000activatestherelay00ontheoutputofPLCcontroller.Conditionalinstructiondoesnthavebefrominputmemoryareaitcanbeanybitfromothermemoryareas,i.e.SRareaasinthefollowingexample.

    Whenoneoftheinstructionsactivatesthebit00inthewordSR200,bit00isactivatedintheoutputwordIR010.Inaword,everyONstateofthebitatinputcausestheOFFstateatoutput.

    E.3ANDLogical"AND"withnormallyopencontacts

    Description Whentwoarelinkedseriallyinoneinstructionline,firstofthemcorrespondstoinstructionsLOADorLOADNOT,whiletheotherrepresentsinstructionsANDorANDNOT.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    AftertheLOADinstructionon00input,ANDinstructionislinkedtoinput01.Instructionontherightwillbeexecutedonlywhenbothoftheconditionsfromthelinearefulfilled,i.e.whenbothinputs00and01areintheONstate.

    E.4ANDNOTLogical"AND"withnormallyclosedcontacts

    Description Whentwoormoreconditionsarelinkedseriallyinoneinstructionline,firstofthemcorrespondstoinstructionLOADorLOADNOT,whiletheotherrepresentsinstructionANDorANDNOT.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    AftertheLOADinstructionon00input,ANDNOTinstructionislinkedtoinput01.Instructionontherightwillbeexecutedonlywhenbothoftheconditionsfromthelinearefulfilled,i.e.wheninput00isinONstateandinput01isinOFFstate.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 10/17

    E.5ORLogical"OR"withnormallyopencontacts

    Description Whentwoormoreconditionscoexistonseparate,paralellinesthatconnectatagivenpoint,thefirstconditioncorrespondstoLOADorLOADNOTinstructions,whileotherscorrespondtoORorORNOTinstructions.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    Inputs00and01areinORrelationwiththeoutput00.OneoftheinputswithONstateissufficienttoactivatetheoutput00.

    E.6ORNOTLogical"OR"withnormallyclosedcontacts

    Description Whentwoormoreconditionscoexistonseparate,paralellinesthatconnectatagivenpoint,thefirstconditioncorrespondstoLOADorLOADNOTinstructions,whileotherscorrespondtoORorORNOTinstructions.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    Inputs000.00and000.01areinORNOTrelationwiththeoutput010.00.Bit010.00willretainONstateuntilbit01changestoONstate(thusbreakingtheconnection,becauseitisnormallyclosed).OneoftheinputswithONstateissufficienttoactivatetheoutput00.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 11/17

    E.7OUTPUTNormallyopenoutput

    Description TheeasiestwayforgettingresultsthatfulfillinputconditionsistheirdirectconnectiontotheinstructionsOUTPUTandOUTPUTNOT.Theseinstructionsareusedforcontrollingthestatusbit,whichisdefinedastheinstructioncarrier.WhenOUTPUTinstructionisused,bitassignedtoitwillbeONiftheexecutionconditionisON,anditwillbeOFFiftheexecutionconditionisOFF.

    Laddersymbol

    Limitations Attentionshouldbepaidnottooverlaptheinstructionsconcerningthebitbeingcontrolled.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    BitIR010.00willremainONaslongasbitIR000.00isON.WhenbitIR000.00changestoOFF,bitIR010.00alsochangestoOFF.

    ThisinstructioncannotbeusedforassigningONorOFFstatestomorethanonebit.Incasethatthereisaneedforassigningvaluestoallofthebitsinword,itcanbedoneonlyonebitatatime.

    E.8OUTPUTNOTNormallyclosedoutput

    Description TheeasiestwayforgettingresultsthatfulfillinputconditionsistheirdirectconnectiontotheinstructionsOUTPUTandOUTPUTNOT.Theseinstructionsareusedforcontrollingthestatusbit,whichisdefinedastheinstructioncarrier.WhenOUTPUTinstructionisused,bitassignedtoitwillbeONiftheexecutionconditionisOFF,anditwillbeOFFiftheexecutionconditionisON.

    Laddersymbol

    Limitations Attentionshouldbepaidnottooverlaptheinstructionsconcerningthebitbeingcontrolled.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    BitIR010.00willremainONaslongasbitIR000.00isOFF,whileprelaskomchangingbitIR000.00toONchangesbitIR010.00toOFF.

    ThisinstructioncannotbeusedforassigningONorOFFstatestomorethanonebit.Incasethatthereisaneedforassigningvaluestoallofthebitsinword,itcanbedoneonlyonebitatatime.

    E.9SETChangesbitstatetoON

    Description InstructionchangesthestateofthespecifiedbittoONwhentheexecutionconditionisON.IncasethattheconditionisOFF,bitstateremainsunchanged(unliketheinstructionOUTwhichchangesbitstatetoOFFevenwhentheconditionisOFF).

    Laddersymbol

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 12/17

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    IfconditionstateonbitIR000.00changestoON,stateofbitIR200.00alsochangestoON.WhenconditionstateofbitIR000.00changesfromONtoOFF,bitIR200.00remainsON.

    E.10RESETChangesbitstatetoOFF

    Description InstructionchangesthestateofthespecifiedbittoOFFwhentheexecutionconditionisON.IncasethattheconditionisOFF,bitstateremainsunchanged.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag Ithasnoeffectonanyparticularflag.

    Example

    IfconditionstateonbitIR000.00changestoON,stateofbitIR200.00changestoOFF.WhenconditionstateofbitIR000.00changesfromONtoOFF,bitIR200.00remainsOFF.

    E.11KEEPChangesbitstateaccordingto2inputs

    Description Instructionisusedformaintainingthestatusofcorrespondingbitaccordingto2inputs.ThefirstinputchangesbitstatetoONwhenevertheconditionofthefirstlineisfulfilled,whilethesecondchangesbitstatetoOFFwhenevertheconditionofthesecondlineisfulfilled.Bitstateremainsunchangedaslongasinputsremainunchanged.

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    Example

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 13/17

    WhenthestateofbitIR000.00changestoONbitIR200.00alsochangestoON.IfbitIR000.01changestoON,bitIR200.00changestoOFFandremainsOFFuntilstateofbitIR000.00isONagain.

    E.12DIFFERENTIATEUPChangesbitstatetoONfordurationofonecycle

    Description InstructionchangesbitstatetoONduringonecyclewhentheprecedingconditionisfulfilled.

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    Example

    InstructionchangesstateofbitIR200.00toONfordurationofonecycle.IfbitIR000.00isON,bitIR200.00changestoONfordurationofonescancycle.

    E.13DIFFERENTIATEDOWNChangesbitstatetoOFFfordurationofonecycle

    Description InstructionchangesbitstatetoOFFduringonecyclewhentheprecedingconditionisfulfilled.

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    Example

    IfbitIR000.00isON,stateofbitIR200.00changestoOFFfordurationofonescancycle.

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 14/17

    E.14NOOPERATIONNooperation

    Description Generally,usageofthisinstructioninprogramsisnotrecommended.WhenPLCgetstothisinstructionnothinghappensandthefollowinginstructionisexecuted.

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    E.15INTERLOCKInterlock

    Description InstructionILisalwaysusedinpairwiththeinstructionILC.Theirpurposeistoresetalltheoutputs,flags,controlbits,timersandcountersthatarewithininstructionsbetweenILandILC.TimersandcountersstopworkingandretainvaluestheyhadatthemomentofexecutingILinstruction.ItispossibletohavemultipleILinstructionsandtoresetoneormorepartsoftheprogram,accordingly.InstructionisexecutedwhenconditionstatechangesfromONtoOFF!

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    E.16INTERLOCKCLEAREndoftheprogrampartencompassedbyinterlock

    Description InstructionILCisalwaysusedinpairwithinstructionIL.WhentheconditionofinstructionILisfulfilledalltheoutputs,flags,controlbits,timersandcountersthatarewithininstructionsbetweenILandILCarereset.TimersandcountersstopworkingandretainvaluestheyhadatthemomentofexecutingILinstruction.

    Laddersymbol

    Flag Ithasnoeffectonanyparticularflag.

    E.17ENDEndofprogram

    Description Thisismandatoryinstructionattheendofeveryprogram.Anyinstructionfollowingthisonewillnotbeexecuted.Itcanbeusedfordebuggingpurposesinprogram,soastodesignatethepointwherethemonitoringofprogramexecutionstops.Iftheprogramusessubroutines,itisnecesssarytohaveinstructionENDfollowingthelastsubroutine.

    Laddersymbol

    Limitations Therearenolimitations.

    Flag ChangesstatesofflagsER,CY,GR,EQandLEtoOFF.

    E.18JUMPJumptoanotherlocationintheprogram

    Description Certainpartoftheprogrammaybeskippeddependingonthestateofdefinedcondition

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 15/17

    forjumpexecution.JumpscanbecreatedusingJUMP(JMP(04))orJUMPEND(JME(05))instructions.IfconditionstateisON,programexecutesnormally,asiftheinstructionwasneverused.IfstatusofexecutionconditionisOFF,programexecutioncontinuesfromtheJUMPENDinstructioncorrespondingtoJUMPinstruction.WhichJUMPENDcorrespondstowhichJUMPinstructionisdefinedwithanumberthatfollowstheinstruction.Value0canbeusedunlimitednumberoftimesinthecourseofprogramforthispurpose,whileeachofother99availablenumbersmaybeusedonlyonce.

    Laddersymbol

    Limitations TotalnumberofJUMPandJUMPENDpairscannotexceed99.Eachvaluefrom199rangecanbeusedonlyonce.

    Flag Ithasnoeffectonanyparticularflag.

    E.19JUMPENDLocationwheretheprogramexecutioncontinuesafterJUMP

    Description InstructionJMEisusedinpairwithJMPinstructionasintegralpartofit.IfthereisnoJMEassignedtoJMPinstruction,programwillreportanerror.

    Laddersymbol

    Limitations TotalnumberofJUMPandJUMPENDpairscannotexceed99.Eachvaluefrom199rangecanbeusedonlyonce.

    Flag Ithasnoeffectonanyparticularflag.

    Example

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 16/17

    WhenthestateofbitIR000.00changestoOFF,jumpinstructionskipsalltheinstructionlinesbetweenitselfandthecorrespondingJMEinstruction.

    Anotherwayforusingjumpinstructionisassigningvalue0toJMPinstruction.UnlimitednumberofjumpscanbeprogrammedinthiswayandthedestinationforeachoftheseisauniquelocationdefinedwithinstructionJUMPENDwithindex0.InstructionJUMPENDwithparameter0maybeusedmultipletimesintheprogram.Inthatcase,programexecutionafterthejumpdefinedwithJUMP(index0)continuesfromthefirstfollowingJUMPENDinstructionwiththisindex.Timeofexecutionwiththisformofjumpfunctionissomewhatlonger,astheprogrammustfirstlocatetheclosestappropriateJUMPENDinstruction.Thefollowingexampledemonstratesprogramminggreaternumberofjumpfunctionsendingatthesamedestination:

    ChangingthestateofbitsIR000.00orIR000.03toOFFexecutesthejumptothelinecontaininginstructionJME.

    E.20TIMERTimerwith0.1sresolution

    Description Timersarecomplexinstructionswiththepurposeofseparatingtwoprogrammingactions.ChangingthestateofconditiontoONstartsthetimingwith0.1sincrementsstartingfromzero.

    ValueofparameterSV(abbreviationforSetValue)ismultipliedby0.1s,theresultbeingtotaltimeinseconds.ValuegiveninthemiddlepartoftheblockiscalledTCnumber.EachTCnumbercanbeusedfordefiningonecounerortimer.Itcantakevaluesfrom000127range.Lowerpartoftheblockisreservedfordisplayingthestartingvalueoftimer.WordwiththisrolecanbelongtosectorsIR,AR,DM,HR,LRorcanbegivenasaconstant,withvaluesfrom000.0999.9range.Themostcommonandthesimplestwaytoapplyatimeristohaveaconstanthere,whethergivendirectlyorprogrammedonsomememorylocation(ifparameterSVisgivenasa

  • 6/25/2015 APPENDIXELadderdiagraminstructions

    http://www.mikroe.com/old/books/plcbook/app_e/app_e.htm 17/17

    constant,itisnecessarytoputcharacter#aheadofvalue).

    Laddersymbol

    Limitations Thenumberoftimercannotbeusedforcounteroranothertimer.

    Flag AffectstheappropriateflaginTCarea.

    Example

    ChangingthestateofbitIR000.00toONstartsthetiming(inthiscase,timeis100*0.1s=10seconds).Afterthepassingofgivenperiodoftime,theappropriatebitIM002changesstatetoON,thusfulfillingtheconditionforexecutingtheinstructionsontheright(inthiscasebitIR010.01changesstatetoON).

    ConditionbitmustbeconstantlyONforagiventimeperiodforbitTIM002tobeset.IfconditionstatechangestoOFFduringthegiventimeperiod,timerresetsandgoesbacktothebeginningofperiod.

    Previouspage Tableofcontents Nextpage

    Copyright2003.mikroElektronika.AllRightsReserved.Foranycommentscontactwebmaster.