Elements of Industrial Automation Week 07 Notes
Elements of Industrial Automation Week 07 Notes
Elements of Industrial Automation Week 07 Notes
Motor Control Relay Logic [Automation Studio] Motor Control PLC Ladder Logic [LogixPro]
C) Subroutines: JSR, SBR, and RET instructions are used to direct the controller to execute a separate
subroutine file within the ladder program and return to the instruction following the JSR instruction. The
SBR instruction must be the first instruction on the first rung in the program file that contains the subroutine.
• Use a subroutine to store recurring sections of program logic that must be executed from several points
within your application program
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 51
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
• A subroutine saves memory because you program it only once.
• Update critical I/O within subroutines using immediate input and/or output instructions (IIM, IOM),
especially if your application calls for nested or relatively long subroutines
• Otherwise, the controller does not update I/O until it reaches the end of the main program (after
executing all subroutines)
• Outputs controlled within a subroutine remain in their last state until the subroutine is executed again.
When the JSR instruction is executed, the controller jumps to the subroutine instruction (SBR) at the
beginning of the target subroutine file and resumes execution at that point. You cannot jump into any part of
a subroutine except the first instruction in that file.
The target subroutine is identified by the file number that you entered in the JSR instruction. The SBR
instruction serves as a label or identifier for a program file as a regular subroutine file. The instruction must
be programmed as the first instruction of the first rung of a subroutine.
The RET instruction marks the end of subroutine execution or the end of the subroutine file. The rung
containing the RET instruction may be conditional if this rung precedes the end of the subroutine.
Sub Routines PLC Example
In the above picture, there are totally 8 files listed. In that SYS 0 and SYS 1
are default files.
LAD 2-Main is the main page of the program, that means PLC starts
executing IO’s from this page only.
LAD-3-IO MAPPING, LAD 4-SCALING, LAD 5-PID, LAD 6-PLANT 1
and LAD 7 PLANT 2 are sub programs categorized by project function and
sequence.
PLC Instruction Description
a) JSR-Jump to Sub routine
We can use this instruction using condition by adding some input before
the instruction like,
In the SBR File number, we should give the ladder number i.e. which sub routine we should call at this place
as shown in figure.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 52
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
Experiment: Develop Ladder Program for relay-based motor control automation such that the motor
reverses its direction when the limit switches are activated
Problem Description
A motor is connected to PLC. Run this motor in the Forward and Reverse direction using Ladder Diagram
programming language.
Problem Solution
• For any three-phase AC motor, reversing can be accomplished by reversing any two leads. For single-
phase motor, reversing start lead with respect to the main leads. And for DC motor, reversing the field
leads with respect to the armature leads.
• There are certain ways to reverse the motor. One is to use DPDT (Double Poles, Double Throw) switch
and another one is by using Reversing Contactors.
• DPDT switch is best suitable for reversing a small DC motor while Reversing Contactor is used to
reverse Three-Phase AC motors.
• Single-phase motors are not widely used for reversing operation. In fact, these are not even available
widely with reversing capability.
• As here we have a three-phase AC motor, reversing any two leads will drive the motor in reverse
direction.
• Contactor is an electrical switch used for switching an electrical power circuit.
• Two magnetic contactors are used, one for forward connections and the other for reverse connections.
• Only Push-Button switches are used to control the direction of this three-phase AC motor.
• We have the input commands to these Push Button switches which are then internally processed by PLC
and then there is the output terminal which activates the corresponding relay to energize the relevant
magnetic contactors.
• Configure forward and reverse wiring of the motor with contactors such that forward contactor is
connected directly in the normal direct phasing of the motor terminal and reverse contactor is connected
with two of the motor terminals in the opposite phase.
• When it is switched to reverse direction, forward rotation does not stop instantaneously hence we have
to determine what time it takes to completely stop one particular direction. Then provide time delay of a
second or two and activate the other contactor.
PLC Program
Here is PLC program to Drive Motor in Forward and Reverse Direction, along with program explanation
and run time test cases.
List of Inputs and Outputs
I:1/0 = Forward Start (Input)
I:1/1 = Reverse Start (Input)
I:1/2 = Stop (Input)
O:2/14 = Latched coil 1 for forward direction (Output)
O:2/0 & O:2/1 = Forward Contactor (Output)
T4:1 = Delay before forward direction (Timer)
O:2/15 = Latched coil 2 for reverse direction (Output)
O:2/2 & O:2/3 = Reverse Contactor (Output)
T4:0 = Delay before reverse direction (Timer)
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 53
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
Ladder Diagram to solve this problem
Program Description
• Important thing to note here that basically programmers do not provide time delay for such applications
where motor has to be run in forward and reverse directions.
• But when motor supply is cut down, it has an actual breaking during which its speed reduces and then
comes to rest.
• So, assuming that the motor takes approximately 10secs to come down to its rest state.
• Suppose the motor is currently running in the forward direction.
• While it is running in the forward direction, O:2/15 coil2 remains de-energized and reverse action is not
activated. TOF is used here so input to T4:0 is true hence timer is not activated.
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 54
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
• When I:1/1 is pressed, O:2/14 coil1 energizes making coil2 O:2/15 de-energized.
• When O:2/15 is de-energized, input to timer T4:1 goes true from false and input to T4:0 goes false from
true.
• Since TOF is used, when input goes true to false, T4:0 is activated. XIO of T4:0/DN is given to Reverse
Coils (O:2/2 and O:2/3) are not energized until timer count is completed. Completion of time delay sets
Done bit to low energizing Reversing Coils (O:2/2 and O:2/3).
• Similar operation happens when motor is running in the reverse direction and forward direction input is
given.
Runtime Test Cases
• Simulation of this problem was successfully performed in software LogixPro of Allen Bradley and
verified using I/O Simulator.
• Instead of actual contactors or motor outputs, simple LED outputs were used to perform this in I/O
Simulator.
Experiment: Simulate the PLC ladder diagram developed for an alarm system
Problem Description
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.
Problem Solution
• 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.
PLC Program
Here is PLC program for Burglar Alarm Security System, along with program explanation and run time test
cases.
List of Inputs and Outputs
I:1/0 = Master Switch (Input)
I:1/1 = Deactivate system (Input)
I:1/2 = Motion Detector (Input)
I:1/3 = Window Sensor (Input)
I:1/4 = Button to Stop Alarm (not the system) (Input)
O:2/0 = Master Coil (Output)
O:2/1 = Alarm Coil (Output)
O:2/2 = Alarm (Output)
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 55
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
Ladder Diagram for Burglar Alarm Security System
Problem Description
• RUNG000 simply shows a latching of a coil O:2/0 to activate the entire security system.
• When Activate button I:1/0 is pressed momentarily, the security system is activated.
• If the system is not activated, alarm does not indicate anything since sensors will have no effects on the
Alarm Coil O:2/1.
• When system is active and Motion detector detects a person, the alarm coil will momentarily go high
activating the Alarm O:2/2 which stays ON until I:1/4 is pressed manually.
• As we can see in RUNG001 that XIO (Normally Closed) contact is used for Window Sensor input I:1/3
because it is normally in true state when not activated. So when the breakage of a window is detected, it
goes false from its true condition allowing Alarm Coil O:2/1 to go high for a moment which in turn
activates Alarm O:2/2.
• In RUNG002, latching has to be provided in order to keep the alarm ringing even if the detection by the
sensors is momentary or to be accurate, pulsating.
Runtime Test Cases
Master Window Motion Alarm
Switch
0 x x 0
0 x x 0
0 x x 0
0 x x 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 56
Vidya Vikas Educational Trust (R),
Vidya Vikas Polytechnic
27-128, Mysore - Bannur Road Alanahally, Alanahally Post, Mysuru, Karnataka 570028
Logic Experiment: Develop a PLC ladder diagram to construct an alarm system which operates as
follows.
- If one input is ON nothing happens.
- If any two inputs are ON, a red light goes ON.
- If any three inputs are ON, an alarm sirens sound.
- If all are ON, the fire department is notified.
• Execute the Ladder
Prepared by: Mr Thanmay J.S, H.O.D Mechanical Engineering VVETP, Mysore Page | 57