UNIT III PROGRAMMING
LOGIC CONTROLLER
Programmable Logic Controllers –
Architecture of PLC – Input / Output
Processing – Ladder Programming –
Instruction Lists – Timers, Internal relays
and counters – Shift Registers –Master
and Jump Controls – Data Handling –
Analogue Input / Output – Selection of a
PLC.
INTRODUCTION
Special form of microprocessor-based controller –
programmable memory – store instruction – implement
logic, sequencing, timing, counting and arithmetic
• Rugged and designed to withstand vibrations,
temperature, humidity and noise
• Have interfacing for inputs and outputs already inside the
controller
• Easily understood programming language
BASIC PLC SYSTEM
Programming device – user
program RAM
Program & data memory –
system ROM & data RAM
Processor – CPU
Communication interface –
address, data, control & I/O
system bus
Power supply – battery
Input interface – buffer,
optocoupler, input channel
Output interface – latch, driver
interface, output channel
INTERNAL ARCHITECTURE
CONT…
INPUT LEVEL
OPTOCOUPLER – electrical
isolation
OUTPUT CHANNEL
• Relay
• Transistor
• Triac
OUTPUT LEVEL
CONT…
Inputting programs – loading program into RAM through
programing device – then to ROM
Forms of PLC
single box – power supply, processor, memory &
input/output unit single box – i/p – 6/8/12/24 – o/p-4/8/16
– 300 to 1000 instructions in memory
rack mounted – separate module for each element
CONT…
Input / output processing
continuous updating – first i/p is read – checked with
program instruction – executed – o/p given out – similarly
next i/p is processed – delay of 3ms for each execution
Mass I/O copying – all the i/p stored – buffer of RAM – as
& program instruction executed o/p are stored – buffer
RAM – last send to the output channel
I/O Addresses – each inputs & outputs has address assigned
to it
LADDER PROGRAMMING
The vertical lines - power rails & the
horizontal lines - rungs.
Each rung - defines one operation in
the control process.
A ladder diagram must read from
left to right and from top to bottom
Each rung must start with an input
& must end with an output
Each rung can have more than one
input but only one output
The input - rung left & the output -
right end of the rung
CONT…
Normally open
Normally
closed
output
Normally open – output occurs
when input is given
Normally closed - output
occurs when input is not given
LOGIC FUNCTIONS
AND OR
NOR NAND
EX-OR
LATCHING
Latching - to hold a coil energized -
the input which energized it ceases
Self-maintaining circuit - maintains
that state until another input is
received
It remembers its last state
Output is given as contact , OR
logic with input contact
Output is released only when input
2 (NC) is energizes
Eg: running a motor – motor
latched with start & stop as NC
INTERNAL RELAY
Do not exist as real-world switching devices - merely bits in the storage
memory - to hold data - behave in the same way as relays - being able
to be switched on or off and switch other devices on or off
Multiple inputs
Multiple outputs
Resetting latch
Battery backed
Master control relay
Jump relay
CONT…
MULIPLE INPUTS – so MULTIPLE OUTPUTS -
many inputs for single single input activates so many
output. Eg: barrier gate outputs. Eg: CNC machine
CONT…
BATTERY BACKED –
RESETTING LATCH – output controlled by internal
unlatching the output relay – remains energized
even after power failure
CONT…
(CJP )
(EJP )
MASTER CONTROL
JUMP RELAY – to perform
RELAY – to control large
a set of instruction if one
number of outputs – turn
condition is satisfied if not do
on/off whole section of
some other set of instruction
ladder diagram
Sequencing
CASCADED Sequencing
TIMERS
Timers - behave like relays with coils - when
energised - result in the closure / opening of
contacts - after some preset time
Timers count fractions of seconds or seconds
using the internal CPU clock.
Different forms of timers:
• Delay on timer
• Delay off timer
• On/off cyclic timer
• Cascaded timer
• Sequencing timer
DELAY ON TIMER
When a input is given timer coil is
activated – after preset time – timer
contact closes – activates the
output
Thus it delays input from reaching
output / output is delayed to
happen
DELAY OFF TIMER
When a input is given – output is
activated - & also timer coil is
activated – after preset time – timer
contact (NC) opens its contact –
deactivates the output
Thus it output is deactivated after
preset time
ON / OFF CYCLIC TIMER
When a input is given timer coil T1
is activated – after preset time –
timer contact closes – activates the
output
And at the same time timer coil T2
also is activated – after preset time
– timer contact (NC) opens its
contact – deactivates the output
Thus an output is activated for
given preset value & deactivated
CASCADED TIMER
A timer can have preset value from 0.1
sec to 999 sec
If the delay time exceeds 999 sec, another
timer is needed for rest of the time
ie for every 999 sec new timers are used
Eg: if there is delay of 1200 sec,
1200-999=201, hence 2 timers one with
999 sec & other with 201 sec is needed
SEQUENCING TIMER
An output may be activated after
preset value of a previous output
being activated
ie, output 2 is activated after n sec
of output 1 activated, delay
between 2 outputs activated is n
sec
Eg; a pump need to be activated
after motor is on but with time
delay of n sec from motor being on
COUNTERS
Built-in elements in PLCs - allow the
number of occurrences of input signals to
be counted.
Eg: items have to be counted as they
pass along a conveyor belt / the number
of revolutions of a shaft / perhaps the
number of people passing through a door.
A counter - set to some preset number
value - when this value of input pulses
received - operate its contacts - normally
open contacts closed - normally closed
FORMS OF COUNTERS
Down-counters count down from the preset value to zero, i.e. events are
subtracted from the set value - counter reaches the zero value - its
contacts change state.
Up-counters count from zero up to the preset value, i.e. events are
added until the number reaches the preset value - counter reaches the
preset value - its contacts change state.
Control for a machine which is required to direct 6 items along one path for
packaging in a box, and then 12 items along another path for packaging in
another box
SHIFT REGISTER
Register – group of internal relay (EG:
4bit, 8 bit, 16 bit etc.,) – space - data
stored
Each internal relay - effectively open or
closed – states being designated as 0 & 1
Shift register - number of internal relays
grouped together – allow stored bits to be
shifted from one relay to another
3 inputs - 1st to load data into the first
location of the register – 2nd command to
shift data along by one location – 3rd to
Cont..
Eg: 8bit register – 8 internal relays
Data stored are given below
First command is given to load input 0 into IR 1
Second command is to shift – hence every data moves by one location –
so a data overflows out at the end
Each internal relay is connected to output so accordingly output
activated (if IR has 1) or deactivated (if IR has 0)
Shift register
DATA HANDLING
Timers, counters & individual internal relays -
concerned with the handling of individual bits
- i.e. single on-off signals
Eg for data handling:
• Data movement
• Data comparison
• Arithmetic operations
• Code conversions
DATA MOVEMENT
Used to move data from one address to another
when an input given in the rung - move occurs from the designated
source address to the designated destination address
Eg: used to move preset value to a timer / counter or from a timer /
counter to a register
DATA COMPARISON
Used to compare two data values – from two different address
when the data comparison instruction is activated - compares the data
from source (S) address to the data in destination (D) address – if true
output is activated or false output is deactivated.
Eg: used to compare a digital value read from some input device with a
second value contained in a register
DATA COMPARISON
• An alarm might be required to be sounded if a sensor indicates a temperature
above 80°C and remain sounding until the temperature falls below 70°C.
• The input temperature data is inputted to the source address and the destination
address contains the set value.
• When the temperature rises to 80°C, or higher, the data value in the source
address becomes ≥ the destination address value and there is an output to the
alarm which latches the input.
• When the temperature falls to 70°C, or lower, the data value in the source
address becomes ≤ the destination address value and there is an output to the
relay which then opens its contacts and so switches the alarm off.
DATA CONVERSION
BCD-to-binary and binary-to-BCD conversions
when the data conversion instruction is activated - converts the
data from source (S) address to the data in destination (D) address
Eg: the input might be for a thumbwheel switch or the output to a
decimal display
ARITHMATIC OPERATION
ADDITION, SUBTRACTION, MULTIPLICATIN & DIVISION
when the arithmetic operation instruction is activated - does the
operation from 2 different address & stores in 3rd address
Analogue input/output
PROPORTIONAL CONTROL OF TEMPERATURE
• Rung 0 reads the ADC and stores the temperature value in data
register DR1.
• With rung 1, the data register DR2 is used to store the set point
temperature.
• Rung 2 uses the subtract function to subtract the values held in
data registers DR1 and DR2 and store the result in data register
DR3, i.e. this data register holds the error value.
• With rung 3 a multiply function is used, in this case to multiply
the value in data register DR3 by the proportional gain of 4.
• Rung 4 uses an internal relay which can be programmed to switch
off DR3 if it takes a negative value.
• With rung 5 the data register DR3 is reset to zero when the input
is switched off.
Temperature Controller
• Rung 0 reads the ADC and stores the temperature value in data register DR1.
• With rung 1, the data register DR2 is used to store the set point temperature.
• Rung 2 uses the subtract function to subtract the values held in data registers
DR1 and DR2 and store the result in data register DR3, i.e. this data register
holds the error value.
• With rung 3 a multiply function is used, in this case to multiply the value in
data register DR3 by the proportional gain of 4.
• Rung 4 uses an internal relay which can be programmed to switch off DR3 if it
takes a negative value.
• With rung 5 the data register DR3 is reset to zero when the input is switched
off.
• Some PLCs have add-on modules which more easily enable PLC control to be
used, without the need to write lists of instructions in the way outlined above.
IEC 1131-
INSTRUCTION
Mitsubishi OMRON Siemens Operation
LIST
Ladder diagram
3
LD LD LD A Load operand into Start a rung with open
result register contacts
LDN LDI LD NOT AN Load negative Start a rung with
operand into result closed contacts
register
AND AND AND A Boolean AND A series element with
open contacts
ANDN ANI AND NOT AN Boolean AND with A series element with
negative operand closed contacts
OR OR R O Boolean OR A parallel element
with open contacts
ORN ORI OR NOT ON Boolean OR with A parallel element
negative operand with closed contacts
ST OUT OUT = Store result register An output from a rung
into operand
SELECTION OF PLC
System (task) requirements. the CPU?
Application requirements. Electrical requirements.
What input/output capacity Speed of operation.
is required? Communication
What type of inputs/outputs requirements.
are required? Software.
What size of memory is Operator interface.
required? Physical environments.
What speed is required of
Devise a timing circuit that will switch on an output for
20 s then off for 1 s, then on for 20 s, then off for 1 s,
and so on.
Devise a timing circuit that will switch on an output
for 10 s then switch it off.
Devise a circuit that can be used to
start a motor and then after a delay of
100 s start a pump. When the motor is
switched off there should be a delay of
10 s before the pump is switched off.
Devise a circuit that could be used with a
domestic washing machine to switch on a pump
to pump water for 100 s into the machine, then
switch off and switch on a heater for 50 s to
heat the water. The heater is then switched off
and another pump is to empty the water from
the machine for 100 s.
Devise a circuit that could be used with a conveyor
belt which is used to move an item to a work
station. The presence of the item at the work
station is detected by means of breaking a contact
activated by a beam of light to a photosensor. There
the item stops for 100 s for an operation to be
carried out before moving on and off the conveyor.
The motor for the belt is started by a normally open
start switch and stopped by a normally closed
switch.
Devise a system, using a PLC, which can be used
to control the movement of a piston in a
cylinder so that when a switch is momentarily
pressed, the piston moves in one direction and
when a second switch is momentarily pressed,
the piston moves in the other direction. Hint:
you might consider using a 4/2 solenoid-
controlled valve.
Devise a system, using a PLC, which can be used
to control the movement of a piston in a
cylinder using a 4/2 solenoid-operated pilot
valve. The piston is to move in one direction
when a proximity sensor at one end of the
stroke closes contacts and in the other direction
when a proximity sensor at the other end of the
stroke indicates its arrival there.
Create a ladder diagram for the following applications:
A pneumatic system with double. Solenoid valves
controls two double acting cylinders A & B. The
sequence of cylinder operations are as follows:
cylinder A extends followed by cylinder B extending,
then the cylinder B retracts and finally the cycle is
completed by the cylinder A retracting. Explain the
logic of the PLC circuit used.
•A pneumatic system with double-solenoid-controlled valves and two
cylinders A and B if limit switches a-, a+, b- and b+ are used to detect the
limits of movement of the piston rod movements in the cylinders and the
sequence required is for the piston rod in A to extend, followed by the
piston rod in B extending, then the piston in B retracting and finally the
cycle is completed by the piston in A retracting.
•An internal relay can be used to switch between groups of outputs to give
the form of control for pneumatic cylinders, which is termed cascade
control.
•Above shows a possible program. When the start switch is closed, the
internal relay is activated. This energises solenoid A+ with the result that
the piston in cylinder A extends. When extended it closes limit switch a+
and the piston in cylinder B extends.
•When this is extended it closes the limit switch b+. This activates the
Internal relay.
•As a result, the B- solenoid is energised and the piston in B retracts.
•When this closes limit switch b-, solenoid A- is energised and the piston in
Furnish the list of PLC Programming Methods.
Design a hardwired relay logic circuit, ladder
logic circuit for the given program.
START PB1
AND CR1
OR LS1
AND NOT CR2
OUT SOL
Consider the problem of the control of a machine which is required to
direct 6 tins along one path for packaging in a box and then 12 tins along
another path for packaging in another box.
•A deflector plate might be controlled by a photocell sensor
which gives an output every time a tin passes it.
•Thus the number of pulses from the sensor has to be
counted and used to control the deflector
•When there is a pulse input to X400, both the counters are
reset.
•C460 starts counting after X400 is momentarily closed.
•When C460 has counted six items, it closes its contacts and
so gives an output at Y430.
•Thus the deflector might be in such a position that the first
six tins passing along the conveyor are deflected into the 6-
pack box, then the deflector plate is moved to allow tins to
pass to the 12-pack box.
•When C460 stops counting it closes its contacts and so
allows C461 to start counting. C461 counts for 12 pulses to
X401 and then closes its contacts.
•This results in both counters being reset and the entire
process can repeat itself
A work piece is loaded on a conveyor belt and
operates between two limits of travel A and B.
When limit switch at station A is activated, the
conveyor moves forward. When limit switch at
station B is activated, the conveyor changes
direction. Pressing the start button causes the
motor to run in the forward direction and
pressing the stop button stops the motor. Create
a ladder logic diagram and explain.