PLC Programming
Basic instructions
Jump and Label
• Jump instruction is used to skip selected ladders’
scan.
• Jump is put on ladder from where scan of ladder
should be skipped. Label is put on the ladder up to
which scan should be skipped.
• Ladders between jump and label are not scanned and
it results no change in coil status.
• Jump has been put in third ladder and it will be active
when I10 is on.
Master Control and Reset
• When master control is active then only scan of ladders
between master control and master control reset will take
place.
• It is opposite of Jump/ Label.
• Ladder number four will be scanned when master control is
active or else it will be skipped.
Subroutine
• Subroutine is used to reduce scan time of program by splitting
it in subroutine when it is a very big logic.
• If there are some set of logic which is being repeated many
times in different conditions then it is better to make a
subroutine file and it can be called from main program
whenever required.
• Subroutine program is scanned when it is called from main
program.
Flag
• Flag is an internal bit memory which has no any
physical existence outside of PLC.
• Flag is a bit memory like input and output. It also gets
on and off, but Outside PLC it has no any existence;
• It is in program only and supports our logic.
• Flag is used to store temporary bit signal.
• In most of plcs it denoted by M
Timer
• we have of 4 types
On Delay Timer
• TON needs continue supply to run. Its done bit get high when accumulator value is
equal to PV
• EN/ Enable bit: Enable bit is the signal from which timer starts running and for on
delay timer it should be continue on.
• PV/ Pre-set valve: pre-set value is the set point. How long you want to run the
timer you need to mention there. It can be millisecond/ MS, second/ S or hour/H.
• ACC/ Accumulator: accumulator is the running/ present/ current value of timer.
You can say it is a display where we monitor the running value of timer.
• DN/ Done bit: Done bit is the confirmation signal of timer. When ACC is equal to
PV, done bit is on.
Off delay timer
• It has also the same parameter as on delay timer
• Its done bit gets high as enable is high and the done bit gets
off when accumulator is equal to PV.
• It delays in turning off the output
TP/ pulse timer
• Pulse time is very much similar to TOF. TOF accumulator runs
when enable is off and TP accumulator runs when enable is
high.
• It does not matter whether enable is a continue signal or a
high pulse. Done bit status is similar to TOF.
RTC/ real time clock
• You can generate signal by comparing your required year, month,
day, hour, minute and second with the accumulator of this timer.
• It is used when you have to control outputs hourly/ daily/ weekly/
monthly yearly wise. For example,
• if you have to stop your machines daily during lunch time or tea
break time automatically or you have to switch off lights and fans
daily during lunch time and during off time of your office.
Important points:
• 1> To switch on use NO contact of the condition signal.
• 2> To switch off use NC contact of the condition signal.
• 3> When we have start signal, we should latch it with some flag.
• 4> When we have any stop signal, we should break the latch directly
from it.
• 5> When we get last signal in our program, we should break all latches
from it. (It means that lastly after one cycle all coils must get off. If any
coil will remain on after one cycle then machine will not run in next
cycle.)
• 6> To repeat process in programs based on many timers, take last signal
and break first timer.
• 7> To repeat process in programs based on many latches, take last
signal and break all latches except start/ first latch.
PLC SCAN/ PLC EXECUTION:
PLC Scan or PLC Execution takes place in three steps; Input scan,
Logic scan and Output scan.
• Logic scan takes place left to write and top to bottom.
• Time taken to complete one scan cycle is one scan time and
this PLC scan time is not fixed. It depends on the length of
program.
• Scan of ladders can be controlled by using Jump and Master
control instructions.
Watch-Dog-Timer
• Maximum scan time set for any controller is Watch-Dog-Timer
• If your program scan time exceeds watch dog timer then PLC will
get reset/ will not execute.
• It also reacts on any kind of software/ hardware malfunctioning
and generate indication on CPU
• Watch dog timer completely monitors PLC execution. Watch dog
timer set for any PLC is 150ms to 200ms.
PULSE
• In very simple, Pulse is a short duration supply.
• In PLC, pulse duration is not fixed but is equal to program
scan time.
• Pulse is of two types; Positive pulse and Negative pulse
• we have different name like rising trigger/ falling trigger, one
sort rise. One sort false etc.
POSITIVE PULSE:
Positive Pulse
• As I0 switch is pressed/ on, immediately positive pulse is
active.
• You can see the switch is continuously pressed but pulse is
not on again. When switch is off and on again then only pulse
& output will get on again.
Negative Pulse
• : You can see the graph of negative pulse. As I0 switch is
pressed/ on, nothing happens to pulse or output. When I0 is
off then only negative pulse is active and gets on and off.
• Negative pulse will be active when switch is off.
Counter
if you have to count anything, you use counter
instruction.
Counter we have of three types; Up counter, down Counter
and Up & down
counter.
CTU/ UP Counter
Whenever enable bit is high counter counts (there are
some counters that count on low state or both states of a
bit signal).
When I0 is on five times, CV is equal (CV>= PV DN on)
to PV and done
bit M0 is on.
CTD/ down counter:
First of all, we need to apply load signal to load PV to
CV
so that it can count down. CTD’s CV displays down
count 4, 3, 2, 1, 0.
DN gets high when CV<= 0. As initially CV is 0 so you
can see in above picture that DN is on initially.
CTUD/ UP & DOWN Counter:
Here CU is the enable of UP counter. CD is the enable of DOWN
counter. RESET is for resetting UP counter (CTU DN off and CV
= 0). LOAD is for reseing DOWN counter (CTD DN off and CV=
PV). PV is the set-point for both CTU and CTD. QU is the done
bit of CTU and QD is the done bit of CTD. CV is the display for
both the counters CTU and CTD.
Pneumatic system
Pneumatic system has air compressor, inlet/ outlet valves and a
cylinder with
piston inside it. Piston is moves by compressed air.
It has two types of cylinder i. e. double acting and single acting. To
operate double acting cylinder two valves are used.
When valve is on, air goes inside the cylinder and piston moves in
forward direction. When valve is off then piston moves in reverse
direction due to spring attached inside and air gets exhausted
Pneumatic System
pneumatic system is used
for low pressure work such
as in clamping, stopper on
conveyor, light object lifting
etc. for home position and
final position feedback of
piston, reed/ magnetic
switch is used on pneumatic
cylinders.
Hydraulic System
Hydraulic system has oil tank, pressure pump, inlet/ outlet
valves and a cylinder with piston inside it.
Compressed oil is used to move piston forward in hydraulic
system. Heavy pressure can be generated in this system.
It is used for heavy task such as in moulding machines, press
machines, earth movers etc. when inlet valve is on compressed
oil goes inside cylinder and moves the piston forward. When
inlet valve is off and outlet valve is on then oil returns back to
oil tank and piston moves back.
Hydraulic System
Single Acting Cylinder
There are two push buttons I0
and I1 for start and stop. There
is a single acting cylinder with
valve Q0. When I0 is pressed
piston will move forward and
when I1 is pressed, piston
should move in reverse
direction.
Double Acting Cylinder
There are two push buttons I0
and I1 for start and stop. Q0
valve for forward and Q1 valve
for reverse. When I0 is pressed
piston should move in forward
direction and when I1 is pressed
piston should move in reverse
direction.
Arithmetic Operations
Addition
Arithmetic operations
Substraction
Arithmetic operations
Multiplication
Arithmetic Operations
Division
Arithmetic Operations
Increment or Decrement