Transcription

Chapter 2: Basic Ladder Logic ProgrammingComputer Aided Manufacturing TECH 4/533501

Ladder LogicLearning objectives Understand basic ladder logic symbol Write ladder logic for simple applications Translate relay ladder logic into PLC ladder logicComputer Aided Manufacturing TECH 4/533502

Simple Ladder LogicLadder Logic: Primary Programming Language for PLCs.Visual and Graphical language unlike textual high-level,such as C, C , Java Derived from relay logic diagramsPrimitive Logic Operations: ORANDNOTComputer Aided Manufacturing TECH 4/533503

Simple Ladder LogicOR Operation Control Behavior: The light should be on when either switch A is on(i.e., closed) or switch B is on (closed). Otherwise it should be off Task: Implement this behavior using Relay circuitPLC Ladder LogicComputer Aided Manufacturing TECH 4/533504

Simple Ladder LogicOR Operation OR Truth TablePossible Combinations of the 2Switches: (22)Computer Aided Manufacturing TECH 4/53350ABLightOFFOFFOFFOFFONONONOFFONONONON5

OR OperationRelay CircuitV L1AARComLRLightBBRCom Switches A and B are connected in parallel to relay coils AR & BR resp. When switch A (or switch B) is closed relay coil AR (or BR) gets energized The Normally Open (NO) contact AR (or BR) gets closed Power is transmitted to coil LR Relay coil LR gets energized The NO contact LR gets closed Power is transmitted to the Light bulbComputer Aided Manufacturing TECH 4/533506

OR OperationRelay Ladder Logic Circuit120vNeutralAARBBRARLRBRLRLampWComputer Aided Manufacturing TECH 4/533507

OR OperationPLC Ladder LogicV ALightComB Append above to the leading two rungs of relay ladder logic diagram Switch A and Switch B are connected to discrete input channels of the PLC Light is connected to discrete output channel (actuator) of the PLCWhen input switch A (or switch B) is onthe light is onComputer Aided Manufacturing TECH 4/533508

Simple Ladder LogicAND Operation Control Behavior: The light should be on when switch A is on (i.e.,closed) and switch B is on (closed). Otherwise it should be off Task: Implement this behavior using Relay circuit PLC Ladder LogicComputer Aided Manufacturing TECH 4/533509

Simple Ladder LogicAND OperationAND Truth Table Possible Combinations ofthe 2 Switches: (22)Computer Aided Manufacturing TECH 4/53350ABLightOFFOFFOFFOFFONOFFONOFFOFFONONON10

AND OperationRelay CircuitV L1V AARBBRLRLightCom Switches A and B are connected in series to relay coils AR & BR resp.When switch A is closed relay coil AR gets energized The Normally Open (NO) contact AR gets closed Power flows to Normally Open (NO) contact BR, where it terminates until BR is energized Subsequently, when BR gets energized, LR is energized, which causes the NO contact LR to close Power is transmitted to the Light bulbWhat happens if BR is energized before AR?Computer Aided Manufacturing TECH 4/5335011

AND OperationPLC Ladder Logic CircuitV AComputer Aided Manufacturing TECH 4/53350BLightCom12

Simple Ladder LogicNOT Operation Control Behavior: The light comes on only when switch Ais on (i.e., closed) and switch B is off (open). Otherwise itshould be off Task: Implement this behavior using Relay circuit PLC Ladder LogicComputer Aided Manufacturing TECH 4/5335013

Simple Ladder LogicNOT OperationNOT Truth Table Possible Combinations ofthe 2 Switches: (22)Computer Aided Manufacturing TECH 4/53350ABLightOFFOFFOFFOFFONOFFONOFFONONONOFF14

NOT OperationRelay CircuitV L1V AARBBRLRLightCom Switches A and B are connected to relay coils AR & BR resp. When switch A is closed relay coil AR gets energized When switch B is off (on) relay coil BR is not energized (energized) and BRcontact is normally-closed (normally-open) Computer Aided Manufacturing TECH 4/5335015

NOT OperationPLC Ladder LogicV AComputer Aided Manufacturing TECH 4/53350BLightCom16

Simple Ladder LogicNAND OperationNAND (NOT AND) Control Behavior: The light comes on only when switch Ais off and switch B is off. Otherwise it should be off Task: Implement this behavior using Relay circuit PLC Ladder LogicComputer Aided Manufacturing TECH 4/5335017

Simple Ladder LogicNAND OperationNAND Truth Table Possible Combinations ofthe 2 Switches: (22)Computer Aided Manufacturing TECH 4/53350ABLightOFFOFFONOFFONONONOFFONONONOFF18

NAND OperationRelay CircuitComputer Aided Manufacturing TECH 4/5335019

NAND OperationLadder Logic CircuitComputer Aided Manufacturing TECH 4/5335020

Digital LogicGatesAND ORA B NAND NOR NOTA BAComputer Aided Manufacturing TECH 4/53350A BA BLightA21

Basic Ladder Logic SymbolNormally open contactPasses power (ON) if coil driving the contact is ON (closed)Allen-Bradley calls it XIC - eXamine If ClosedNormally closed contactPasses power (ON) if coil driving the contact is off (open)Allen-Bradley calls it XIO - eXamine If OpenOutput or coilIf any left-to-right path of inputs passes power, output is energizedAllen-Bradley calls it OTE - OuTput EnergizeNot Output or coilIf any left-to-right path of inputs passes power, output is de-energizedThe IEC 61131-3 standards describe the complete list ofladder logic contact and coil symbols. See also section 2.3.1Computer Aided Manufacturing TECH 4/5335022

PLC Ladder LogicSymbols The symbols are ladder logic instructionsThe PLC scans (executes) the symbols: on Closed True 1 off Open False 0 Every PLC manufacturer uses instruction symbolsIndustry trend is based on IEC 61131-3 Variations in symbols by ManufacturersAllen-Bradley ControlLogix symbols slightly different (Refer 2.3.3)Computer Aided Manufacturing TECH 4/5335023

Ladder Logic DiagramInput (Condition)Instructions Power Rails - Pair of Vertical Lines Rungs - Horizontal Lines Contacts A, B, C, D arranged onrungs Note in PLC Ladder Logic: No Real Power Flow (like in relayladder) There must be continuous path thru’the contacts to energize the outputABDEFGOutputInstructionCOut1HOut2KContinuous path for logic continuityPower flowsComputer Aided Manufacturing TECH 4/5335024

Ladder Logic DiagramInstructionsInput (Condition)InstructionsAB Output: Appears on extreme RHS ofrung always – Out1, Out2DE Input: Any instruction that can replacea contactFGTwo Classes of Ladder Logic InstructionsOutputInstructionCOut1HOut2KContinuous path for logic continuityPower flowsCan contacts appear on the RHS of a coil?Computer Aided Manufacturing TECH 4/5335025

Ladder Logic DiagramFunction Block InstructionsFunction Block Instructions Any non-contact instruction: Timer Instruction Counter Instruction Comparison InstructionComputer Aided Manufacturing TECH 4/53350E( )( )HInputFunctionBlockOutputFunctionBlock26

Ladder Logic DiagramExample 1Task:Draw a ladder diagram that will cause the output, pilot light PL2, to beon when selector switch SS2 is closed, push button PB4 is closed andlimit switch LS3 is open. (Note: no I/O addresses yet.)Thought Process Identify the output: PL2 PL2 appears on rhs of rung What is the behavior (type of connection to use):sequential operation of all switches series connection Type of contacts to implement output:SS2 closedPB4 closedComputer Aided Manufacturing TECH 4/53350LS3 open27

Ladder Logic DiagramExample 1SS2PB4Computer Aided Manufacturing TECH 4/53350LS3PL228

Ladder Logic DiagramExample 2Task:Draw a ladder diagram that is equivalent tothe following digital logic diagramABC DE YY is on when (A is on, B is on and C is off ) or D is on, or E is offWhat is the Boolean logic expression?Computer Aided Manufacturing TECH 4/5335029

Ladder Logic DiagramExample 2 Thought Process Identify the output: Y Coil Y appears on rhs of rungWhat is the behavior (type of connection to use): The inputs A, B, C for AND gate will be connected in seriesThe D, E inputs for OR gate will be connected in parallel with the output of ANDgateType of contacts to implement output (review the expected behavioragain to determine contact types):A is on:B is on:D is on:Computer Aided Manufacturing TECH 4/53350C is off:E is off:30

Ladder Logic DiagramExample 2BACYDEWhat happens if the D contact refers to Y?Computer Aided Manufacturing TECH 4/5335031

Ladder Logic DiagramSealing an outputBACYYEOutput Y is set (latched) indefinitelyComputer Aided Manufacturing TECH 4/5335032

Ladder Logic Diagram DangersRepeated Output Do not repeat normal output coils that refer to the sameaddressABCOut1DEOther ladder logicFGHOut1K The coils for first and second rung refer to Out1 Second rung overrides the logic in first rungComputer Aided Manufacturing TECH 4/5335033

Ladder Logic Diagram DangersRepeated Output - Correction First consider the output Next, consider ALL the conditions that drive the output (Out1)(Implement the conditions in parallel)Computer Aided Manufacturing TECH 4/5335034

Ladder Logic Diagram Dangers Use set/seal (latch) and reset (unlatch)together: If a set coil refers to an output there should be areset coil for that outputReverse power flow in contact matrix is notallowed Power flow one way left to right (solid state relays)Computer Aided Manufacturing TECH 4/5335035

Ladder Logic Diagram DangersReverse Power Flow This is not allowed:L1ABCDE If the reverse power flowpath is truly needed, thenput it as a separate path,where the power flows fromleft to right:Computer Aided Manufacturing TECH 4/53350AL2ReversePower FlowFL1PL1BCDEFDBFEPL1L2C36

Typical PLC Processor Scan Major tasks in a scanRead InputsExecute Ladder LogicScan TimeUpdate Outputs Processor must read the state of the physical inputs and set the state ofthe Physical outputsComputer Aided Manufacturing TECH 4/5335037

Typical PLC Processor Scan Order of PLC Processor Scan Read Physical Inputs Scan ladder logic program Write the physical outputs Scan Time StartUpdateOutputsReadInputsProgram(ladder logic)executionTime to complete above cycleOrder of 1-200 millisecondsWhat could happen if scan time exceeds more than 200 milliseconds?Computer Aided Manufacturing TECH 4/5335038

Typical PLC Processor ScanScenario 2 The state of actual inputdevices are copied to an areaof the PLC Memory, input datatable before the ladder logicprogram executesState cProgramRunsOutputImage(PLCMemory)State ofActualOutputDevice As the ladder logic program is scanned, it reads the inputdata table then writes to a portion of PLC memory - theoutput data, table as it executes The output data table is copied to the actual output devicesafter the ladder logic has been scanned.What is the significance of the input and output data tables?Computer Aided Manufacturing TECH 4/5335039

Typical PLC Processor ScanAllen-Bradley RSLogix 5000The execution of PLC Processor controlled byprocessor mode (Refer to lab 1) Run Mode: Physical Input, Physical Outputs and Ladder logic allget scannedRemote Mode Down load ladder logic to PLC Processor; andinitiate scan from the remote terminalProgram Mode Ladder logic not scannedComputer Aided Manufacturing TECH 4/5335040

Ladder Logic Evaluation For most PLC's, the ladder scan starts at the top of the ladder andproceeds to the bottom of the ladder, examining each rung from leftto right. Once a rung is examined, it is not examined again until the next scan.The rungs are not examined in reverse order.The JMP instruction may be used to jump back up the ladder andexecute earlier rungs. Use of JMP not recommended Why?Computer Aided Manufacturing TECH 4/5335041

Ladder Logic EvaluationPush Button (PB)Scan 1Start L40Physical Input: PBPhysical Outputs: PL1, PL2, PL3 and PL4Computer Aided Manufacturing TECH 4/53350Start of PLC scansState of PLC image memory for I/O devices:42

Ladder Logic EvaluationPush Button (PB)Scan 1: Only the state of PB changes to ON (1)during the scanScan 2:The ON state of PB is copied into Input data tablebefore Ladder logic is scannedWhen rung 1 is scanned PL1 is still off (o)When rung 2 is scanned PL2 is still off (o) Why?What is the value of PL4 and PL3 in Output Data table?When rung 3 is scanned the Value of PL3 in the output datatable changes to 1 Why?When rung 4 is scanned, the Value of PL4 in the output datatable remains at off (0). Why?At the end of scan 2 the values in Output data table are copiedto the Physical Output Devices. PL 3 turns onComputer Aided Manufacturing TECH 4/5335043

Ladder Logic EvaluationPush Button (PB)Scan 3:When rung 1 is scanned the value of PL4 in output data tableis still 0 PL1 in output data table remains 0When rung 2 is scanned the value of PL3 in Output Data table iscurrently 1 value of PL2 in Output Data table changes to 1When rung 3 is scanned the Value of PB in the input datatable is still1 Value of PL3 in Output data table remains at 1When rung 4 is scanned Value of PL2 in the output data table isnow 1 so the value of PL4 in the Output Data table changes to 1At the end of scan 3 the values in Output data tableare copied to the Physical Output Devices:PL2 and PL4 turn on simultaneously(PL3 remains on)Computer Aided Manufacturing TECH 4/5335044

Ladder Logic EvaluationPush Button (PB)Scan 4:When rung 1 value of PL4 in output data table is now 1 value of PL1 in output data table changes to 1When rung 2 is scanned the value of PL3 in Output Data table isstill 1 value of PL2 in Output Data table remains at 1When rung 3 is scanned the Value of PB in the input datatable is still1 Value of PL3 in Output data table remains at 1When rung 4 is scanned Value of PL2 in the output data table isstill 1 so the value of PL4 in the Output Data table remains at 1At the end of scan 4 the values in Output data tableare copied to the Physical Output Devices:PL1 turns on(PL2, PL3 and PL4 remain on)Computer Aided Manufacturing TECH 4/5335045

Ladder Logic EvaluationPush Button (PB)Scans 5 and 6: Nothing ChangesScans 7 – 9 : Similar