Apc M-2
Apc M-2
MODULE-2
2.1PLC Instructions
2.1.1 What is logic? PLC programming languages
2.1.2 Ladder programming-Conventional ladder Vs. PLCladder
MODULE 2
PLC INSTRUCTIONS
2.1 Introduction
• Conventional hardwired relay ladder diagrams represent actual hardwired control
circuit.
• In a hardwired circuit there must be electrical continuity before the load will energize.
• PLC ladder logic was modelled after the conventional relay ladder there is no
electrical continuity in PLC ladder logic.
• PLC ladder rungs must have a logical continuity before the output will energize.
5. The resulting ON or OFF action, as a result of solving each rung, is sent to the output
status file for storage.
6. During the output update portion of the scan, the processor will send the ON or OFF
signal from each bit in the output status file to the associated output screw terminal by
way of the output module.
Individual ladder-programming symbols are represented as instructions in the CPU section of
Figure 2-2. The notations I: 01, I:02, and O:01 represent the instructions and their addresses.
When programming the PLC, these instructions are entered one by one and stored
sequentially in the user program portion of the processor's memory. When the PLC is in run
mode, these instructions are combined to arrive at the resulting ON or OFF state of each
rung's output.
Figure 2-2 Signal flow into and out of a PLC. Notice that there is no electrical continuity
between the inputs and the controlled output.
The PLC follows, or executes, the instructions stored in its memory. For example a packaged
grape drink. The package instructions instruct you to do the following:
Devices in an electrical schematic diagram are described as being open or closed. PLC ladder
instructions are typically referred to as either true or false. When a PLC solves the user
program, it is said to be solving the ladder logic.
Fig 2-3
Closing switch 1 and switch 2 will provide power, or electrical continuity, to L-1. This is illustrated in
Figure 2-6.
Fig 2-6
Possible combinations that switch 1 (SW1) and switch2 (SW2), and the resulting output signals. (Fig
2-7 Truth table for AND logic)
From the truth table, you can see that only when switch 1 AND switch 2 are ON will the
output (light 1) energize.Figure 2-8 is an example of the ladder program instructions that
would be entered using a handheld programmer and an Allen-Bradley MicroLogix 1000. The
ladder rung in Figure 2-8 is identical to that in Figure 2-6 except that the symbols have been
changed to PLC ladder format.
Fig 2-8
Here is the program listing for the MicroLogix 1000 if you are entering the program with a
handheld programmer:
LOAD I1
AND I2
OUT 05
• The instructions tell the processor to load input 1(I1) into memory, AND it with input
2 (I2), and then output the result to output 5 (O5). The resulting output will be
determined by the truth table (Figure 2-7).
• The truth table in Figure 2-9 can also be represented as shown in Figure 2-10.
Fig 2-11 Three Input series circuit Fig 2-12 Three Input AND circuit
The instructions tell the processor to load input 1 (I1) into memory, AND it with input 2 (I2), AND
the result of the previous logical operation with input 3 (I3), and OUTPUT the result to output 1 (O1).
If all three inputs are false. If Il, which is false, is loaded into memory and then ANDed with 12,
which is also false, the result of this logical AND operation is false. Now we AND I3, which is false,
to the result of I1 and 12, which was false. ANDed with 13, the output is also false.
The rule of OR logic is that if any input is true, the output will also be true. OR logic also states that if
all inputs are true, the output will be true. In Figure 2-15, if switch 1 OR switch 2 is energized, light 1
will energize. If both SW 1 and SW 2 are true, the output will also be true.
Fig: 2-15
Figure 2-16 illustrates Figure 2-15 converted to a PLC ladder rung. A PLC rung of logic will
have normally open or normally closed contacts instead of normally open or closed switch
symbols. Addresses and instructions are included.
Fig : 2-16
Fig:2-17
In case of the OR circuit, if either switch is ON, the output will be true. In addition, if both
switches are ON, the output will be true. Figure 2-18 shows a three-input parallel circuit,
using three-input OR logic. The following is a PLC program listing from
LOAD I1
OR I2
OR I3
OUT 02
The instructions tell the processor to load input 1 (I1) into memory, OR it with input 2 (I2),
then OR the resultant of the previous logic operation with input 3 (I3), and then output the
result to output 2 (O2).
Let's assume that inputs II and I3 are false, and input I2 is true. If Il, which is false, is loaded
into memory and then ORed with I2, which is true, the result of this logical OR operation is
true. Now OR I3, which is false, with the result of II and 12. That resultant was true; OR ed
with I3, which is false, its output is true. If any or all inputs are true, the output is true.
A normally closed hardwire relay contact passes power any time the relay coil is not
energized. Likewise, the normally closed PLC ladder logic instruction will pass power any
time the input status .file bit is not a 1. This means that the physical hardware input is not
sending an input signal into the PLC's input module.
NOT logic is the opposite of a normally open PLC instruction or contact. It can be used in
conjunction with AND or OR logic when a logical 0 in the status file is expected to activate
some output device.
The NOT logic function is used when an input must not be energized for an output to be
energized.
The truth table in Figure 2-20 simply states that a normally closed instruction on a PLC
ladder rung will be the inverse, or opposite, of the input status table bit associated with the
specific instruction.
If the input status table bit is a 1, or true, the normally closed instruction will be false. In
comparison, when the input table status bit is false, or a 0, the associated normally closed
instruction will be true.
Figure 2-21 illustrates two rungs, the first with a normally open instruction and the second
with a normally closed instruction.
Fig 2-21 Conventional ladder diagram illustrating normally open and normally closed relay
contacts controlling load, L-1.
ANALYSIS OF RUNG #1
• Instruction I1 will energize the output only when there is a logical 1 in its associated
input status file bit. A 1 in this bit position will cause the normally open instruction to
become true and change state.
• In changing state, the instruction will allow logical continuity to pass on to the output
instruction and make it true.
• Instruction I1 is considered true when it passes logical continuity. If there is no valid
input signal from the field device attached to I1 screw terminal on the input module, a
logical 0 will be placed in the input status file.
• A logical 0 in the input status file will result in .this normally open input instruction
becoming false. Being false, the instruction will not pass logical continuity.
ANALYSIS OF RUNG #2
• The normally closed instruction works much like the normally closed contacts on a
hard-ware relay. Being normally closed, instruction I2 will energize the output only
when there is a logical 0 in its associated input status file bit.
• Even though there is a logical 0, or false input signal, in the status file, the normally
closed instruction is true and passes logical continuity on to the output instruction. If
there is a valid ON input signal from the field device attached to I2's input module
screw terminal, a logical 1 will be placed in the input status file.
• A logical 1 in the input status file will cause the normally closed instruction to
change state. The normally closed instruction will change from true (closed) to false
(open).
• Being false, the normally closed instruction will not pass logical continuity to the
output instruction. Without logical continuity, the output instruction will become
false.
A parallel ladder rung with normally closed inputs is a rung containing OR NOT logic.
Figure 2-22, a PLC ladder rung, has two input instructions, one normally open and one
normally closed. This circuit contains parallel NOT logic. This conventional schematic
rung will be true under the conditions shown in Figure 2-23. Input I must be true OR
input 2 must NOT be true to make this rung true and energize output L-1.
Let's look at the following ladder and program for an Allen7Bradley MicroLogix 1000 (Fig
2-24).Notice that the normally closed instruction is referred to as "OR invert" (ORI).
LOAD
OR I2
ORI I3
OUT O2
Fig 2-24
The instructions tell the processor to load input 1 (I1) into memory, OR it with input 2 (I2),
then OR invert (OR a normally closed instruction), with the resultant of the previous logic
with input 3 (I3) then being output to output 2 (O2).OR logic states that when any or all
inputs are true, the associated output will be true.
Fig:2-25 Fig:2-26
The exclusive OR logic function will allow either input 01 OR input 02, but not both
together, to control the output (Fig 2-27).
Fig:2-27
The logic for exclusive OR (X-OR) would look as follows (Fig 2-28).
• If normally closed input I1 is true and input I2 is left as is, the logic on the main rung
will become true, thus energizing the output. As for the state of the normally closed I1
instruction on the parallel branch, with the normally open input instruction true or
closed, the normally closed contacts for input I1 on the parallel branch will open.
• With the normally closed contacts from input I1open on the parallel branch, input I2
cannot control the output.
• Input I2's logic will operate in the same manner. If 12's normally open instruction
becomes true while I1's instructions remain in their normal state, the parallel branch
will become true. With the parallel branch true, the rung will be true.
• The rung output will become true as there is logical continuity on the parallel branch.
With the normally open I2 closed on the parallel branch, the normally closed I2 on the
main rung will open and prevent I1 from controlling the output.
• If, by chance, both input 1 and input 2 are energized their normally closed
counterparts will both open. With an open on the main rung and the parallel branch,
there is no way for the rung to become true.
• Contacts and coils are the basic symbols found on a ladder diagram. Normally open or
normally closed contact symbols are programmed on a given rung to represent input
conditions that are to be evaluated by the processor as it solves the user ladder
program.
• Rung contacts are evaluated to determine how output, instructions are to be controlled
by the PLC.
• Each output is represented by a coil symbol.
• Contacts and coils are also referred to as bit or relay instructions.
• Each input or output is represented by a separate bit in the input or output Status file.
Figure 2-29 presents a generalized overview of the basic instructions available in most
PLC processors.
• Instructions direct the PLC as to how to respond to bits found in its memory.
• Bits in PLC memory are typically input status file bits representing ON or OFF
signals input into the status file from an input module.
BIT Instructions
Instruction Symbol Use this Instruction
Normally open or As a normally open, or examine if ON, input
Examine ON instruction on your ladder rung
Normally closed or As a normally closed, or examine if OFF, input
Examine OFF instruction on your ladder rung
One-shot --[OSR]-- To input a single digital pulse from a maintained
input signal
To latch an output ON. Output stays ON until the
Latch Output coil unlatch instruction becomes true
The normally open instruction is used by all PLCs.The SLC 500 and MicroLogix use
the term "examine if closed" (XIC) to represent the normally open instruction. Other PLC
manufacturers might use "examine if ON- to identify the normally open instruction. We
are focussing on Allen Bradley SLC 500 family of PLCs.
Fig 2-30 shows how the normally open instruction is evaluated by the PLC processor’s
CPU.
Fig:2-30
The examine if closed instruction tells the processor to test for an ON condition from
the reference address bit. The reference address bit could be an input device in the
input status file, an output bit from the output status file, or an internal bit used as
either an output or a status bit from other instructions.
Fig: 2-31
Fig 2-32
• The normally closed, or examine if open, instruction is addressed in the same manner
as the normally open instruction.
Rung Operation
• When input 1:1/2 on the first rung is energized, the output-latch instruction, address 0:2/3,
is energized. The output-latch instruction will remain latched ON and will be unaffected,if
input 1:1/2 changes.
• Use the output-unlatch instruction to turn OFF, or unlatch, the output that was turned on by
the latching instruction. The unlatch instruction with the same address must energized to
unlatch the output address that was latched ON.
Fig 2-34 unlatch instruction used alone to unlatch an addition instructions overflow status bit
Programming consideration
• Figure 2-37 has the unlatch instruction programmed after the unlatch instruction. In this
case, the last instruction—the latch instruction—will take precedence and keep the output
latched, provided both the latch and unlatch rungs are true.
Fig: 2-38
• A PLC program could be developed directly from this ladder rung, as illustrated in Figure
2-39.
Fig 2-39
• A PLC was designed to simulate relay ladder logic, relay operation is a key building block
in understanding, and how input signals from hardware input devices must interact with
programming instructions.
• When the relay is at rest, the normally open push-button input is not actuated and the
relay coil is not energized. The relay's normally closed contacts will remain closed and
Light A will be lit in Figure 2-40.
• When the push button is closed, the relay coil will be energized and its associated
contacts will switch. The normally open contacts, now closed, will pass power. Light A
will turn off as its contacts are open, and Light B will energized. (Fig 2-41).
• Fig 2-42 illustrates a normally closed push button, which allows power to flow
continuously to the relay coil. With the relay coil energized, Pilot Light B will remain on
as long as the normally closed push button allows power to flow to the relay coil.
• When the normally closed push button is depressed (Fig 2-43) power will be interrupted
to the relay's coil. As the coil loses power, the normally open contacts, which have been
held closed, will open. Normally closed contacts will pass power as they return to their
normal state. Pilot Light A will then energize.
Fig 2-44 summarizes the relay status in conjunction with the input status buttons.
Fig 2-44
Circuit operation
• When converting to PLC ladder logic, the CR-1 coil and its associated contacts become
internal to the PLC and are not represented on the PLC ladder program. Because CR1-I
and its associated contacts no longer exist, the PLC output instruction will be used to
latch the ladder logic.
• To receive maximum flexibility from a PLC, connect each input to the PLC input
module separately so that the PLC ladder program can be used to combine each input as
required to satisfy any control problem.
• Fig 2-46 shows separated inputs wired to a PLC input module.
Fig 2-47 Start Push button status reflected in the input status table. The OFF signal will be reflected
as a 0 in the input status table
Fig 2-48 start-stop input bit status from input hardware in a nonenergized state
Many conventional schematics place the normally closed overload contact after the starter coil on the
rung. Because most PLCs require that all input instructions be programmed before the output
instruction, the conventional schematic must be converted.
• The first step in converting a conventional schematic to PLC management is to determine
inputs and outputs. The overload relay's normally closed contacts will be a physical
hardwired input.
• After they have been determined, separate inputs from outputs.
• While separating inputs and outputs, move the overload contacts to the input side of the
output.
• Assign inputs their addresses and enter the proper instructions on the ladder.
The overload contacts in a motor starter are closed during normal operation. Being a normally
closed set of contacts like the normally closed stop push button, the proper instruction on a PLC
ladder rung will be normally open. (Fig 2-50)
Fig 2-50 conventional motor starter circuit converted for PLC system management
Overload relay contacts are programmed as normally open, as the normally closed stop push
button. This input will always pass power except when the motor starter is in an Overload
condition. In an overload condition, the normally closed overload contacts will open and de-
energize the start-stop control circuit.