You are on page 1of 70

PLC Programming

Dr. Manjula Sutagundar


Dept. of E&IE, BEC, Bagalkot
Unit-2
PLC Instructions: The basic relay instructions
normally open and normally closed
instructions, Output latching instructions,
Understanding relay instructions and the
programmable controller input modules,
Interfacing start stop pushbutton and motor to
PLC, Developing ladder diagram with
analytical problems.

Dept. of E&IE, Basaveshwar Engineering College, Bagalkot,


Sub: Process Automation Faculty Incharge: Dr. Manjula A.S.
Basic Relay Instructions
• Instructions that operate on single bit
• Also known as bit instructions
• Bit instructions:
 Normally open contact
 Normally closed contact
 Output coil
 Negated output coil
 Latch output coil
 Unlatch output coil
 One shot rising
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Normally Open Instruction
• Commonly known as NO contact or Examine if
closed.
• The normally open (NO) is true when the
input status bit controlling the contact is 1
• Typically represents any input. Can be a switch or
a pushbutton, a contact from a connected
output, or a contact from internal output
• Has a bit level address which is examined for an
on condition
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Normally Open Instruction

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Normally Open Instruction

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Normally Open Instruction

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Normally Closed Instruction

• Commonly known as NC instruction or Examine


if open
• The normally closed (NC) is true when the
input status bit controlling the contact is 0.
• Typically represents any input. Can be a switch or a
pushbutton, a contact from a connected output, or a
contact from internal output
• Has a bit level address which is examined for an on
condition Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Normally Closed Instruction

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Normally Closed Instruction

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Output Coil Instruction

• Coils represent relays that are energized when


power flows to them.
• Typically represents any output that is controlled by
some combination of input logic. Can be a
connected device or an internal output.
• If any left to right path of input conditions is true,
the output is energized.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Status Bit Examples

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Status Bit Examples

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Rung Continuity

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Basic logic function
• AND Function

A B C

• Series logic means that all the instructions in the rung (A AND B) must be true
in order for output instruction to be true

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Basic logic function
• OR Function
• A

• B

In the rung above, it can be seen that either input A or B is be true (1),
or both are true, then the output C is true (1).

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Basic logic function
• Not function

A C

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Basic logic function
• NAND function

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Basic logic function
• NOR Function

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Negated Coil Instruction

• Coils represent relays that are energized


when power flows to them.
• If any left to right path of input conditions is
false, the output is energized.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• A lighting control system is to be developed. The
system will be controlled by four switches, SWITCH1,
SWITCH2, SWITCH3, and SWITCH4. These switches will
control the lighting in a room based on the following
criteria:
 Any of three switches SWITCH1, SWITCH2, and SWITCH3, if
turned ON can turn the lighting on, but all three switches
must be OFF before the lighting will turn OFF.
 The fourth switch SWITCH4 is a Master Control Switch. If
this switch is in the ON position, the lights will be OFF and
none of the other three switches have any control.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• An output has to be generated when any one
of 4 sensors gives a high output.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• An output light is to be turned on when switch
S1 and S2 are both turned on or when switch
S3 is turned on. Otherwise the light should
remain off.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• An output light is to be turned on, when either
switch S1 or switch S2 is turned on. The light
should remain off when both the switches are
on or both are off.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• Write a PLC program to implement the
conditional logic statements below.

A PLC output is to switch on if any of three inputs


is switched on.
A PLC output is to switch on if any one of three
inputs is switched on but not two or more.
A PLC output is to switch on if any two outputs are
switched on, but not the third.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• A fire alert system consist of a red indicator
bulb, a buzzer and alert call to fire station. The
fire detection is by means of three sensors
fitted in different location. The red light should
turn on if any one of the sensor detects a fire.
The buzzer should turn on when any two
sensors detect the fire and An alert call should
be sent to the fire station when all the three
sensors detect fire
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples
• A level control system consist of a process
tank, a reservoir, a pump, a level sensor,
reservoir water indicator. A pump is required
to be activated and pump liquid into process
tank when the start switch is on, the level of
the liquid in the tank is below the required
level and there is liquid in the reservoir from
which it is to be pumped.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Latch Output Coil

• Used to maintain or latch an output ON even if the status


of the input logic that caused the output to energy
• When any logical path on the ladder rung containing the
latching instruction has continuity, the output referenced
to the latching instruction is turned on
• The output remains on even if the rung’s logical
continuity or PLC system power is lost
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Unlatch Output Coil

• Used to de-energize an output energized by a


latch instruction
• The latch instruction will remain in latched ON
condition until an unlatch instruction with
same reference address is energized
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Rules for Latch and Unlatch Instructions

• Latch and unlatch instructions are used in pairs


• Latch and unlatch pair of instruction must have the
same reference address
• The latch and unlatch ladder rungs need not be
grouped in the ladder program
• Latching and unlatching instructions are retentive
provided if the PLC battery is installed and is in good
condition
• If an unlatch instruction is left energized, the
associated latching output cannot be latched
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Programming Considerations
• The placement of the latch and unlatch
instruction within a ladder rung can affect the
behavior of these instructions
• The last instruction programmed on the rung
will take precedence over other instructions
• The

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Example Programs
• We need to start/stop the motor using start
stop push. When the start button is pushed
we want to start the motor, and when the stop
button is pushed we want to stop the motor.
Note that when the push button is pushed
the input will go on as long as the button is
pushed otherwise it will go off.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Example Programs
• Develop a PLC ladder logic for a level control
system. When the system is started, if the
level in the tank is below the level sensor the
inlet valve should open. The valve should
remain open until the water reaches level
sensor or stop button is pressed.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Example Programs
• In some level control system operator fills tank
manually by operation of water pump
manually.
• In this situation operator waits when tank is
being filled because when tank reaches to
high level, water pump should be stopped.
• And also water pump should remain in ON
condition until tank reaches the high level.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Programming Normally Open and Normally
Closed Push Buttons

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Programming Normally Open and Normally
Closed Push Buttons
• Develop a PLC ladder program to control an
output using a normally open start push
button and normally closed stop push button.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
PLC Programming Examples

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
2.Consider the design of a Burglar Alarm for a
house. This alarm will be activated if an
unauthorized person is detected by a Window
Sensor or a Motion Detector. Implement this
Alarm System in PLC using Ladder Diagram
programming language.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• Basically two sensors are used, one is Motion Detector and
other one Window Sensor.
Window sensor is nothing but a loop of wire that is a piece of
thin metal foil which encircles the window.
• The motion detector is designed such that when a person is
detected, the output of sensor goes true.
• Important thing to note here is that in Window Sensor,
current is always passing until there is a breakage in glass of a
window. Hence output is always true. When alarm system is
active and someone tries to break the window, current does
not flow through the metal foil causing output to go false.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
3. In the next figure we want to fill the two tanks
with water by a pump. The pump is operating
manually by a push-button “Start”. When the
first tank becomes full, the circuit
should automatically start to fill the second
tank by closing the first valve, and opening the
second valve, and when the second tank is full,
the pump disconnects automatically and a “sign
lamp” is turned on to show that 2nd tank is full.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
• 4. Develop a PLC ladder logic to select one out of four
motors based on the two control inputs C1 and C2. If C1
and C2 are OFF then motor M1 is selected. The motor
M1 when selected can run if S1 is ON else it will not run.
If C1 is OFF and C2 is ON then motor M2 is selected. The
motor M2 when selected can run if S2 is ON else it will
not run. If C1 is ON and C2 is OFF then motor M3 is
selected. The motor M3 when selected can run if S3 is
ON else it will not run. If C1 and C2 are ON then motor
M4 is selected. The motor M4 when selected can run if
S4 is ON else it will not run
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
• 5. Develop a PLC ladder logic to mix two
liquids in certain proportion in a process tank.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• 6. Providing lubricant for the gear box before
the lathe spindle starts to run which aims to
ensure that the oil pump motor starts first and
the main motor starts subsequently

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• This program is a typical application of the conditional control
circuit. Y0 = ON when Oil Pump START button is pressed.
Therefore, the oil pump will start to provide lube for the gear box
of main motor(Y1)
• Under the precondition of the operating state of the Oil pump,
the main motor (Y1) will be ON when the Main motor START
button is pressed.
• During the operation of main motor (Y1), oil pump (Y0) needs to
provide lube continuously.
• The oil pump will be stopped when Oil pump STOP button X2 is
activated, and the main motor will be stopped when Main motor
STOP button X3 is activated.    
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
• 7. Detecting the standing bottles on the
conveyor and pushing falling bottles in tray.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• 8. A Double acting pneumatic cylinder needs
to be controlled using two pushbuttons.
Pneumatic cylinder is advanced by pressing
two push buttons simultaneously. If any one of
the push button is released, cylinder comes
back to initial position.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• 9. Two double acting cylinder are to be
controlled using two push buttons. When
pushbutton PB1 is pressed cylinder1 extends
and cylinder2 retracts. When pushbutton PB2
is pressed cylinder2 extends and cylinder1
retracts.

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
• 10. Develop a PLC ladder logic to control the
running of a conveyor. The conveyer system is
activated and deactivated using a NO start switch
and NC stop switch. A sensor at the one end of the
conveyor is used to detect the material. If the
material is present, then the conveyor must run so
as to carry the material to the other end. The other
end is fitted with a sensor to detect the material
and when the material reaches other end the
conveyor must stop.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Bit Instructions
• One Shot Rising
 Allows an event to occur only once
 Controls the one-shot output for particular output address
 Instruction looks for an OFF to ON transition in the input
 The one shot instruction is energized when the logic
preceding it becomes true
 The OSR will be energized when the input instruction goes
from false to true
 The referenced output instruction goes true for one scan
 Following the scan in which the OSR instruction is true, the
referenced output instruction goes false
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Bit Instructions
• Applications of OSR
 Reset the desired condition in one scan
 To read the current value of thumbwheel switch one
time
 A momentary push button actuation could be used to
increment the speed on the motor. Speed could
increment one step for each push
 Used along with mathematical instruction to perform
a calculation once per scan
To send data to output display devices
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Bit Instructions
• Internal bit type instructions
 To control the instructions other than output on a
rung
 Internal bits can be incorporated in the user
program other than the real world field devices
 can be called as internal bits, internal coils,
internal relays
 can be used as a rung output when real output is
not desired

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Bit Instructions
• Internal bit type instructions are stored in their
own file
• In Allen Bradley PLC the default bit file is file 3
• Bit File Addressing:
 B3:1/3
 B – The designator for bit file
 3 – File number
 : - file separator
 / - bit separator
Dept. of E&IE, Basaveshwar Engineering
College, Bagalkot, Dr. Manjula A.S.
Bit Instructions

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.
Bit Instructions

Dept. of E&IE, Basaveshwar Engineering


College, Bagalkot, Dr. Manjula A.S.

You might also like