PLC Programs PDF
PLC Programs PDF
Problem Description
A parking plot has total capacity of Cars. Number 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.
PLC Program
Here is PLC program for a Car Parking System, along with program explanation and run time test
cases.
List of Inputs and Outputs
I:1/0 to I:1/4 = IR Sensor to detect the presence of cars (Inputs)
O:2/0 to O:2/4 = LEDs to indicate presence of car spots (Outputs)
C5:0 = To increment when Car exits (Counter Up)
C5:0 = To decrement when Car enters (Counter Down)
O:6 = Display address (Output)
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.
PLC Program to Control Level of a Single Tank
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.
List of Inputs and Outputs
I:1/0 = Level High Switch (Input)
I:1/1 = Level Low Switch (Input)
O:2/0 = Inlet Valve (Output)
O:2/1 = Outlet Valve (Output)
I:1/14 = Start (Input)
I:1/15 = Stop (Input)
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.
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.
List of Inputs and Outputs
I:1/0 = Start (Input)
I:1/1 = Stop (Input)
B3:0/0 = Latched Coil Bit (Bit)
T4:0 = Timer to update output sequence (Timer)
SQO = Sequencer output (Sequencer)
O:2/0 = North-South Green Light (Output)
O:2/1 = North-South Yellow Light (Output)
O:2/2 = North-South Red Light (Output)
O:2/3 = East-West Green Light (Output)
O:2/4 = East-West Yellow Light (Output)
O:2/5 = East-West Red Light (Output)
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.
Problem Description
By using a control valve which is operated with standard pneumatic signal 3-15psi, level of
a tank is to be maintained. Implement automation of this tank level system in PLC using
Ladder Diagram programming language.
Problem Diagram
Problem Solution
To measure the continuous level, Ultrasonic Sensor may be used.
Rosemount 3100 series Ultrasonic Level Transmitters can be used to measure the level of the
tank.
Range of these transmitters is 9-11m.
Output of these transmitters is in standard electrical signal 4-20mA. Convert this standard signal
into digital signal by connecting level transmitter to Analog Input Module of PLC.
Calibrate the transmitter and set output such that it gives 4mA when tank is empty and 20mA
when tank is full. Convert this data in accordance to level in Centimeters.
This gives output such as 0000h when input is 4mA and FFFFh when output is 20mA. Determine
the level of tank to be maintained. Convert preset value to be the maximum output that means if
the level to be maintained is 370cm, then convert value such that output is FFFFh when level is
370cm.
At low level, valve must be fully open, so air to close valve is used here to maintain the inlet flow.
Program
Here is PLC program to Maintain Level of a Tank, along with program explanation and run
time test cases.
List of Inputs and Outputs
I:1/0 = Start (Input)
I:1/1 = Stop (Input)
O:2/0 = Latching Coil (Output)
DIV = Division block (Compute)
MUL = Multiplication block (Compute)
MOV = Move instruction to move data (Logical)
N7:0 = Input from transmitter in Hex form (Register)
N7:2 = Storing conversion FFFFh into equivalent 400cms (Register)
N7:3 = Conversion of preset cms into equivalent hex (Register)
O:3 = Output to which I-P converter is connected (Output)
Ladder diagram to maintain the level of a tank
Program Description
RUNG000 is a latching rung to operate the system through Master Start and Stop PB.
RUNG001 comprises all the conversion needed to control level of the tank.
Output of transmitter is in current signals which is 4-20mA.
When output is 4mA, Analog Input Module converts it into 16bit equivalent hex numbers. Hence
when input to Analog module is 4mA, it stores 0000h into register and when 20mA, it stores
FFFFh into register. Here register N7:0.
Let’s say here height of the tank is 4m or 400cm. By converting it into equivalent hex, change in
value per centimeter is 164.
Value of N7:0 is then multiplied with 173 because when Level reaches 380cm, output is 62259 in
decimal. So when output at 380cm is multiplied with 173, we get full FFFFh at N7:2 to operate
valve to fully close.
This multiplication is stored into N7:2 register. Digital to Analog conversion of value stored in
N7:2 is performed inside the processor and equivalent mA current is received from terminal O:3.
Current to Pneumatic converter then converts current signals into equivalent 3-15psi pneumatic
signal and adjusts valve opening.
Problem Description
Implement various mathematical functions in PLC using Ladder Diagram programming
language.
Problem Solution
Use all the Math Instructions to implement various Mathematical Arithmetic Functions.
Use ADD to add one piece of data to another.
Use SUB to subtract one piece of data from another.
Use MUL to multiply one piece of data by another.
Use DIV to divide one piece of data by another.
Use SQR to find the square root of a piece of data.
Use NEG to change the sign of a piece of data.
PLC Program
Here is PLC program to do Mathematical Functions, along with program explanation and
run time test cases.
List of Inputs and Outputs
I:1/0 = Input to Add (Input)
I:1/1 = Input to Subtract (Input)
I:1/2 = Input to Multiply (Input)
I:1/3 = Input to Divide (Input)
I:1/4 = Input to find Square Root (Input)
I:1/5 = Input to change the sign of a Number (Input)
N:7/0 to N:7/9 = Integer Number Location (Input)
O:6 = Display (Output)
Ladder Diagram to implement mathematical arithmetic functions
Program Description
Program is very clear to understand.
N7:0 to N7:9 contain Integers of which operation is to be performed.
In the ADD instruction, data of N7:0 and N7:1 are added and sent to destination which is Display
with output address O:6.
Similarly all other operations are performed.
Though, we must know that the answers stored in the destination are in Hexadecimal form,
hence we have to convert this data into BCD form and then send it to display output O:6.
PLC Program to Control Level of Series Tanks
This is a PLC Program to Control Level of Series Tanks.
Problem Description
Two tanks are connected with each other through a pipeline in series. Level of both tanks is
to be controlled. Implement this operation in PLC using Ladder Diagram programming
language.
Problem Diagram
Diagram showing tanks in series operation
Problem Solution
Assume that the storage tank has more capacity than the feeder tank.To measure level of both
tanks, level switches are installed.
Outlet valve is operated by another process and it is operated according to the requirement. So
outlet flow varies. Inlet valve is to be operated by PLC to control the level.
Use interlocking to control the inlet valve.
Connect Level Switches to the input module of PLC. Connect inlet valve with the output module
of PLC.
PLC Program
Here is PLC program to Control Level of Series Tanks, along with program explanation and
run time test cases.
List of Inputs and Outputs
I:1/14 & I:1/15 = Start & Stop (Input)
I:1/0 = LHST1 high level switch of storage tank (Input)
I:1/1 = LLST1 low level switch of storage tank (Input)
I:1/2 = LHST2 high level switch of feeder tank (Input)
I:1/3 = LLST2 low level switch of feeder tank (Input)
O:2/0 = Inlet valve (Output)
Program Description
RUNG000 is used for latching the bit B3:0/0 through which Master Start and Stop can be
performed. Memory Bit is used here to save an output terminal.
RUNG001 performs controlling of Inlet Valve which is connected to O:2/0 of output module.
O:2/0 energizes when I:1/1 or I:1/3 goes high which is set by Low level switch of storage tank or
by low level switch of feeder tank respectively.
Similarly it is closed when high level of storage and feeder tank detected.
Problem Description
Two tanks are connected in parallel with a stream line. Heat and Cool the same material
and control level of both tanks. Implement this in PLC using Ladder Diagram programming
language.
Problem Diagram
Problem Solution
Heater is used to heat the material and cooling water supply is used to cool down material
temperature.
Inlet valve feeds Material to both tanks.
One tank stores material for heating purpose and the other stores material for cooling purpose.
Level switches are used to detect Low level and High level in both the tanks.
Outlet valves are installed in the bottom of both the tanks to drain products for further process.
Mount temperature sensors to measure temperature of both the tanks.
Controlling of these tanks is independent of inlet flow assuming inlet flow to be constant.
PLC Program
Here is PLC program to Control Level of Parallel Tanks, along with program explanation
and run time test cases.
List of Inputs and Outputs
I:1/0 = Start PB (Input)
I:1/1 = Stop PB (Input)
I:1/2 = LLST1 Low level of Tank 1 (Input)
I:1/3 = LHST1 High Level of tank 2 (Input)
I:1/4 = LLST2 Low level of Tank 2 (Input)
I:1/5 = LHST2 High level of Tank 2 (Input)
B3:0/0 = Latching bit (Bit)
O:2/0 = V2 To heating tank (Output)
O:2/1 = V4 outlet from heating tank (Output)
O:2/2 = V3 To cooling tank (Output)
O:2/3 = V5 outlet from cooling tank (Output)
N7:0 = Register to store temperature reading of heating tank (Register)
N7:1 = Register to store temperature reading of cooling tank (Register)
Ladder Diagram to solve this problem
Program Description
RUNG001 is to control V2 Valve. This is operated whenever Low level of Tank1 is detected or if
Low level or high level both are not detected.
RUNG002 is to control V4 valve. This is operated whenever Temperature data of tank 1 is
greater than or equal to 70o C.
Latching of V4 is not provided because it is independent of Inlet valves. Even if the tank is half
empty but temperature is more than 70oC, outlet valve of the tanks open.
Similarly RUNG003 and RUNG004 work and V3 and V5 are operated.
Problem Description
Whenever a part is placed on the drilling table, pneumatic clamper clamps the part and
drilling process is done. When drilling is done, clamper releases the part by releasing
pressure. When another part is detected, the process is repeated. Implement this in PLC
using Ladder Diagram programming language.
Problem Diagram
Problem Solution
Set lower and upper limit of a motor to stop and start the drilling process. This is done for precise
drilling and to obtain uniformity.
Pressure operated clamping device is used to hold the objects firmly. This is operated by 20psig
air supply which is provided when an object is detected.
Limit detection object is placed on the motor to detect upper and lower limit by the switches.
PLC Program
Here is PLC program to Operate Drilling of Parts, along with program explanation and run
time test cases.
List of Inputs and Outputs
I:1/14 = Start (Input)
I:1/15 = Stop (Input)
O:2/15 = master coil (Output)
O:2/0 = Clamping Device (Output)
O:2/1 = Drilling Motor (Output)
O:2/2 = Motor Down (Output)
O:2/3 = Motor Up (Output)
I:1/0 = Object detect switch (Input)
I:1/1 = Lower Limit (Input)
I:1/2 = Upper Limit (Input)
Program Description
RUNG001 is to operate Clamping device with address O:2/0, Motor Down Coil O:2/2 and Drilling
Motor O:2/1.
These outputs are operated when an object is detected.
Clamping device and Motor Down coil is de-energized when Lower Limit of drilling motor is
detected which is connected to I:1/1. And Drilling Motor O:2/1 is de-energized when Upper Limit
I:1/2 is detected.
RUNG002 is to operate Motor Up coil with address O:2/3. When Lower limit is reached that
means drilling is completed. Next operation is to take Drilling motor back to its main position and
for that reverse coil Motor Up coil with address O:2/3 is energized.
When it is reached to its main position that is Upper Limit I:1/2, reversing Motor Up coil is de-
energized.