Programming Examples 1
Programming Examples 1
Problem Description
A parking plot has total capacity of Cars. Numbers of empty spots are displayed on the
display outside the Parking Plot and which spots are available is to be indicated by
LEDs. Implement this in PLC using Ladder Diagram programming language.
Problem Solution
Counter is used to count the number of empty spots.
Proximity Sensors or IR Sensors are used to detect the presence of car.
Here in this system IR Sensor can be well installed to make this system cost
efficient since Proximity Sensors are costly than IR Sensors.
Value of counter is displayed on the display which is mounted outside the parking
plot.
This counter value is converted into decimal.
Display arrangement
PLC Program
Here is PLC program for a Car Parking System, along with program explanation and run
time test cases.
Program Description
Counter Up CTU and Counter Down CTD are used to determine the Exit and
Entry of cars respectively.
Value 5 is already stored in the accumulator since only 5 number of spots are
there in this Parking Plot.
So whenever car enters or exits from the Parking area, the value in the counter is
incremented and decremented accordingly.
Accumulator holds decimal values, this value thus sent to the display through
BCD converter which converts Decimal digits into equivalent Binary Coded
Decimal signals.
Display receives whatever the value Accumulator holds, in terms of BCD.
I:1/5 and I:1/6 are two inputs from other two IR Sensors to detect the exit and
entry of cars accordingly.
Here again, CTU and CTD both have the same address in order to vary
accumulator value of both counters according to Exit and Entry of cars.
XIO (Normally Closed) contact is used here for IR Sensor outputs so that LED is
ON when the spot is empty.
Problem Description
A classroom has a capacity of maximum 120 students. There are two doors, one for
Entry and the other for Exit. When number of students in the classroom is less than 120,
Entry door has a Green light on it which remains ON. When number of students in the
classroom is 120 or more than that, Red light goes ON turning OFF the Green light
which indicates that the classroom has reached its maximum capacity and is full.
Problem Description
Considering the availability of two separate doors for Entry and Exit, two separate
Proximity Switches can be used to detect entry and exit of students.
One proximity switch is mounted at the Entry door and the other at the Exit door.
Both the switches will generate two different outputs which can be then fed to
PLC to operate the lights according to the Ladder Logic Program written in its
memory.
Counter must be used to count the number of students entering and exiting.
Comparator must also be used to compare the count value with the given
maximum capacity of 120.
PLC Program
Here is PLC program to Maintain the Capacity of a Particular Classroom, along with
program explanation and run time test cases.
Program Description
Problem Description
There are total four number of outputs which should be run one by one with a particular
time delay. Implement this in PLC using Ladder Diagram programming language.
Problem Solution
Generate Master Start and Stop buttons to activate the sequence and define four
outputs.
Use TON timer to generate a particular time delay, same or different.
Use Done bit of first timer to energize other output and activate second timer.
Repeat this process until the final output is energized and last timer is activated.
Reset timers after the completion of first cycle if necessary.
Use LEDs as output to test the program.
PLC Program
Here is PLC program to Operate 4 Outputs Simultaneously with Time Delay, along with
program explanation and run time test cases.
Problem Description
Implement controlling of various lights in PLC using Ladder Diagram programming
language using timers. Retentive Timer is suggested to use.
Problem Solution
Define order of lights.
Provide timers to lights, to each individually if necessary.
Reset timers automatically or use reset coil to reset timers.
Double check if the order of light is made correctly and connections are made
properly.
Use latching coil for Master Start and Stop for prevention against malfunctioning.
0.1 Time Base function availability is useful to turn ON and OFF a light.
By using this, we can make lights blink.
This is one method to solve this problem by using timers.
Retentive Timers have a capability of storing the previous values at which timer
was stopped or input was withdrawn.
Hence Retentive Timer RTO can be used here so that in case of power failure,
program can be restarted from where it was left previously.
PLC Program
Here is PLC program to Control Lights in a Sequence, along with program explanation
and run time test cases.
Problem Description
Implement controlling of Traffic Lights in PLC using Ladder Diagram programming
language.
Problem Solution
There are two methods to solve this problem. One is by using stack operation
and the other one is by using sequencer output method.
Sequencer output method is best suited for this problem since very less
configuration is needed and program length is also reduced.
In this method, we need to assign SQO instruction by configuring all the
parameters given in the instruction.
File, Mask, Dest, Control, Length and Positions are parameters which we need to
configure.
File : It is the starting address for the registers in the sequencer file.
Mask : Mask is the bit pattern through which data flow happens from source to
the destination address. If there is 1 in the masking, it passes values and if 0, it
blocks the data flow.
Dest : It is the address of the input to which the Sequencer Output instruction
moves the data.
Control : Is the address that contains the parameters with control information for
the instruction. EN, DN and ER are bit which sets according to the status of
sequencer output. EN and DN bits are set just as in timers. ER bit stands for
Error bit, it is set when a negative position/length value is detected by the
processor, or zero length value.
Length : It is the number of steps of the sequencer file starting at position 1.
Position 0 is the start-up position.
Position: It indicated the steps that is desired to start the sequencer instruction.
The start position is all zeros, this is represented as the neutral position; so no
outputs will be turned ON in position 0.
So to start the actual function of output sequence, Position 1 is determined as
starting sequence while programming.
Integers or Bit Registers are used as Destination Address.
PLC Program
Here is PLC program to Control Traffic Lights, along with program explanation and run
time test cases.
Program Description
RUNG000 again here is for Master Start and Stop the process.
File; #N7:0 and File length is 10, hence output sequence is varied from N7:0 to
N7:10 with each input.
Destination is set to O:2 hence with each transition, N7:0 to N7:10 are moved to
O:2 with masking.
O:2/0 to O:2/5 are used as the output address to Traffic Lights and hence Mask
has value 003Fh which means data flow of N7:0/0…N7:10/0 to N7:0/5…N7:10/5
is passed and the remaining N7:0/6…N7:10/6 to N7:0/15…N7:10/15 are blocked.
Control parameters are assigned to register R6:0.
Sequence of traffic lights to be operated are stored in the registers from N7:0 to
N7:10 as following.
Time base is set to 4secs, hence after every 4secs, output sequence is changed
to its next register pattern outputs which is then transferred to O:2 and O:2/0 to
O:2/5 are energized accordingly.
As we can see, from N7:1 to N7:4 have the same bit pattern. So, these bits are
set to 1 for 4 cycles that is 16secs. These bits are used for South-North Green
light and East-West Red light.
Similarly the entire sequence is followed.
When Stop I:1/1 is pressed, Position is reset to 0 and all the outputs are de-
energized.
PLC Program to Control Level of a Single Tank
« Prev
Next »
This is a PLC Program to Control Level of a Single Tank.
Problem Description
One open tank is installed in the plant of which liquid level is to be controlled. When level
reaches the Level Low, Outlet flow is blocked and inlet flow is allowed until high level is
achieved. And when Level High is detected, outlet flow is allowed and inlet flow is
blocked.
Problem Diagram
Diagram of a single tank level control
Problem Solution
To detect high and low level of liquid in the tank, two level switches are used
which gives output in digital terms, that is when corresponding levels are
detected, it gives output high otherwise remain low.
To control level of this system, Single Acting piston valve can be used which has
two states, either fully open or fully close.
Low Level Switch is mounted at the bottom of the tank and Level High switch
mounted at the side upper most position.
When this inputs are detected, output to Control Valve has to be latched in order
to continuously fill or empty the system.
Master start/stop is also provided to shut down or start the entire process.
PLC Program
Here is PLC program to Control Level of a Single Tank, along with program explanation
and run time test cases.
Program Description
RUNG000 is simply for latching a coil and master start-stop buttons.
RUNG001 is to control the outlet valve through O:2/1. This is done when Level
High is detected.
Latching of Output O:2/1 is done because when High Level is detected, input to
RUNG001 is temporary, like Push Button. So in order to keep outlet valve open
until the Level Low I:1/1 is detected, latching is done. XIO of Level Low Switch is
connected in series so that when Level Low is detected, it goes true closing the
outlet valve.
Similarly in RUNG002, it works exactly same. The only difference in RUNG002 is
that extra I:1/14 contact in parallel with LLS.
Suppose when the system is started and the tank is partially filled, neither LHS
nor LLS is detected, in this case, outlet and inlet valves remain closed while inlet
valve should open to start filling the tank because it’s partially filled.
To eliminate this error, I:1/14 (Start) is connected in parallel to LLS I:1/1 contact.
This checks if LHS (I:1/0) is detected or not. If LHS is not detected, then it opens
the inlet valve until LHS is detected.
PLC Program for Heating Liquid in the Tank by Heater
« Prev
Next »
This is a PLC Program for Heating Liquid in the Tank by Heater.
Problem Description
Controlling heating of Liquid in the tank using heater. Implement this process in PLC
using Ladder Diagram programming language.
Problem Diagram
Problem Solution
To detect high and low level of liquid in the tank, two level switches are used
which gives output in digital terms, that is when corresponding levels are
detected, it gives output high otherwise remain low.
To control level of this system, Single Acting Piston valve can be used which has
two states, either fully open or fully close and to heat the liquid, heater is used.
Low Level Switch is mounted at the bottom of the tank and Level High switch is
mounted at the side-upper most position.
Heater is installed inside the tank and temperature sensor such as RTD or
Thermocouple may be used to detect the temperature of liquid in the tank.
PLC Program
Here is PLC program for Heating Liquid in the Tank by Heater, along with program
explanation and run time test cases.
Program Description
RUNG000 is simply for latching a coil and master start-stop buttons.
RUNG003 is to control the outlet valve through O:2/1. This is done when
Temperature is above 50°C. When temperature is greater than 50°C, outlet valve
starts draining the liquid. XIO of Level Low Switch is connected in series so that
when Level Low is detected, it goes true closing the outlet valve.
Similarly in RUNG001, it works exactly same. It is energized when Level Low is
detected. The only difference in RUNG001 is that extra I:1/14 contact in parallel
with LLS.
Suppose when the system is started and the tank is partially filled, neither LHS
nor LLS is detected, in this case heater output does not get energized and
heating is not controlled.
To eliminate this error, I:1/14 (Start) is connected in parallel to LLS I:1/1 contact.
This checks if LHS (I:1/0) is detected or not. If LHS is not detected, then it opens
the inlet valve until LHS is detected and heating is started.
In RUNG002, heater coil O:2/2 energizes when LHS I:1/0 is detected and heating
is started. This is done until temperature reaches 50°C, O:2/1 is energized de-
energizing O:2/2 which in turn stops heating.
Problem Description
Parts are moved on the conveyor. Count the number of parts collected at the end of the
conveyor and display it on the display in PLC using Ladder Diagram programming
language.
Problem Diagram
Problem Solution
Mount Proximity Switch to detect the parts.
Use output of proximity to counter as an input to increment data.
Convert this number into appropriate numerical and show number of parts
collected.
Most widely Inductive and Capacitive Proximity switches are used to detect parts.
Inductive Proximity are used to detect metal objects while to detect other objects,
Capacitive Proximity Switch is most widely used.
Capacitive Proximity detection capability ranges from 1 to 25mm distance.
Mount this sensor according to the size of parts present on the conveyor and
width of conveyor so that this sensor can detect parts easily.
CUP is used to increment the number of parts collected.
PLC Program
Here is PLC program for Counting of Parts from Conveyor, along with program
explanation and run time test cases.
Program Description
RUNG000 is the master start/stop rung used to start and stop the counting
process.
RUNG001 is to count the number parts collected. Counter Up with address C5:0
is to count the number of parts collected. Whenever a part is detected by
Proximity Switch, I:1/5 goes true momentarily and it increments accumulator
value of the counter.
RUNG002 is used to convert Decimal numbers into Binary Coded Decimal.
Source address is given as C5:0.ACC and destination address is given as O:6
which is of Display. Converted BCD number is decoded by the display and the
value present in accumulator of CUP C5:0 is displayed.