04 - Programming Continous
04 - Programming Continous
M 1
PROGRAMMING OF PLC
Types of PLC Programming Language
Instruction List (IL) Structured text programming (ST)
Basuwaqi, A. M 2
PROGRAMMING OF PLC
Ladder diagram Programming
• A ladder diagram is a means of graphically representing the logic required in a relay
logic system, representing +V and 0V
• Consists of a number of rungs connecting two vertical lines.
Basuwaqi, A. M 3
PROGRAMMING OF PLC
Ladder diagram Programming
Basuwaqi, A. M 4
PROGRAMMING OF PLC
Ladder diagram Programming (Function blocks)
• The term function block diagram (FBD) is used for PLC programs described in terms of
graphical blocks.
• A function block is a program instruction unit which, when executed, yields one or
more output values
Basuwaqi, A. M 5
PROGRAMMING OF PLC
Ladder diagram Programming (Function blocks)
Logic gates
Basuwaqi, A. M 6
PROGRAMMING OF PLC
Ladder diagram Programming (Function blocks)
Logic gates
Basuwaqi, A. M 7
PROGRAMMING OF PLC
Ladder diagram Programming (Function blocks)
Ladder diagram and equivalent functional block diagram
Basuwaqi, A. M 8
PROGRAMMING OF PLC
Ladder diagram Programming (Function blocks)
Basuwaqi, A. M 9
PROGRAMMING OF PLC
Boolean Algebra
Ladder programs can be derived from Boolean expressions since we are concerned with a
mathematical system of logic. In Boolean algebra there are just two digits, 0 and 1.
AND OR NOT
Consider:
Basuwaqi, A. M 10
PROGRAMMING OF PLC
Boolean Algebra
Consider:
Basuwaqi, A. M 11
PROGRAMMING OF PLC
Boolean Algebra
Example
Basuwaqi, A. M 12
PROGRAMMING OF PLC
solution
Basuwaqi, A. M 13
JUMP & CALL
Introduction
The jump instruction which enables part of a program to be jumped over and the way in
which subroutines in ladder programs can be called up.
Basuwaqi, A. M 14
JUMP & CALL
Mitsubishi vs Allen-Bradley
Mitsubishi, The jump instruction is denoted Allen-Bradley PLC-5 format the jump takes place from
by CJP (conditional jump) the jump instruction (JMP) to the label instruction (LBL).
Basuwaqi, A. M 15
JUMP & CALL
Siemens
JMP which is executed if the input is a 1 and another jump instruction JMPN which is
executed if the input is 0. The end of both instructions is the label DEST
Basuwaqi, A. M 16
JUMP & CALL
Jumps within jumps
Basuwaqi, A. M 17
JUMP & CALL
Subroutines: Allen-Bradley
Subroutines are small programs to perform specific tasks which can be called for use in
larger programs
Basuwaqi, A. M 18
JUMP & CALL
Subroutines: Mitsubishi
Basuwaqi, A. M 19
JUMP & CALL
Subroutines: Siemens
Siemens a similar format can be adopted, using CALL to call up a subroutine block and RET
to indicate the return instruction to the main program. However, a function box approach
Basuwaqi, A. M 20
TIMERS
Mechanical Timing Relays
Basuwaqi, A. M 21
TIMERS
Treatment of timers
Basuwaqi, A. M 22
TIMERS
Types of timers
There are a number of different forms of timers that can be found with PLCs.
IEC 1131-1 standards. BOOL indicates a Boolean input/output, i.e. on/off. IN is the input. Q is the output. ET is
the elapsed time output. PT is the input used to specify the time
Basuwaqi, A. M 23
TIMERS
Programming of timers
All PLCs generally have delay-on timers, small PLCs possibly having only this type of timer
Mitsubishi Siemens
S is Boolean start input.; TV is duration of time specification; R is Boolean reset. BI is current time value in
binary word; BCD is current time; value in BCD word; Q is Boolean output; indicating state of timer.
Basuwaqi, A. M 24
TIMERS
Treatment of timers
Basuwaqi, A. M 25
(c) Telemecanique, (d) Toshiba, (e) Allen-Bradley
TIMERS
Sequencing
When the input In 1 is on, the output Out 1 is switched on. The contacts associated with this
output then start the timer. The contacts of the timer will close after the preset time delay, in
this case 5.5 s. When this happens, output Out 2 is switched on
Basuwaqi, A. M 26
TIMERS
Cascaded timers
• Timers can be linked together, the term cascaded is used, to give longer delay times than are
possible with just one timer.
• we might have timer 1 with a delay time of 999 s. This timer is started when there is an input
to In 1. When the 999 s time is up, the contacts for timer 1 close. This then starts timer 2.
This has a delay of 100 s
Basuwaqi, A. M 27
TIMERS
On-off cycle timer
On-delay timers can be used to produce an on-off cycle timer. The timer is designed to
switch on an output for 5 s, then off for 5 s, then on for 5 s, then off for 5 s, and so on
Basuwaqi, A. M 28
TIMERS
Off-delay timers
on-delay timer can be used to produce an off-delay timer. With such an arrangement, when
there is a momentary input to In 1, both the output Out 1 and the timer are switched on
Basuwaqi, A. M 29
TIMERS
Off-delay timers
Some PLCs have, as well as on-delay timers, built-in off-delay timers and thus there is no
need to use an on-delay timer to produce an off-delay timer
Basuwaqi, A. M 30
TIMERS
Off-delay timers
Basuwaqi, A. M 31
TIMERS
Off-delay timers
Basuwaqi, A. M 32
TIMERS
Pulse timers
Basuwaqi, A. M 33
TIMERS
Example : Flash Light
Create a program that could be used to flash a light on and off as long as there is some
output occurring
Solution:
Basuwaqi, A. M 35
COUNTERS
Introduction
• Mechanical counter: Every time the actuating lever is moved over, the counter adds one
number; the actuating lever then returns automatically to its original position.
• Electronic counters: can count up, count down, or be combined to count up and down.
Although the majority of counters used in industry are up-counters, numerous applications
require the implementation of down-counters or of combination up/down-counters
Basuwaqi, A. M 36
COUNTERS
Introduction
Basuwaqi, A. M 37
COUNTERS
Introduction
Basuwaqi, A. M 38
COUNTERS
CTD & CTU
Forms of representation of
counters:
RST is reset.
CD is count down input,
LD is for loading the input,
PV is for the preset value,
CV the current count value,
CU is count up input,
R is for the reset input
Basuwaqi, A. M 39
COUNTERS
Programming
When there is a pulse input to In 1, the counter is reset. When there is an input to In 2, the
counter starts counting. If the counter is set for, say, 10 pulses, then when 10 pulse inputs have
been received at In 2, the counter’s contacts will close and there will be an output from Out 1
Basuwaqi, A. M 40
COUNTERS
Programming
Mitsubishi Siemens
Basuwaqi, A. M 41
COUNTERS
Programming
Toshiba
Allen Bradly
Basuwaqi, A. M 42
COUNTERS
Programming
IEC 1131-3
standard symbol for
up/down counter
Basuwaqi, A. M 46
COUNTERS
Up and down counting
Basuwaqi, A. M 47
TIMERS
Example 2 : traffic light (HW)
Solution
Basuwaqi, A. M 48
Internal relays
Introduction
Storage Function (Memo): Memory is written as software and not execute as hardware
Internal Relays (Flags) : Internal signal is used to inform us that a specific action is done
Basuwaqi, A. M 49
Internal relays
Introduction
• Internal relays are imaginary programmed relays that are not connected to any real
output but have coils and contacts. Since they are not addresses for real outputs,
internal relays cannot have addresses that start with "Q". Instead they have addresses
of the user selection that starts with "M" like "M0.0 “
Basuwaqi, A. M 50
Internal relays
Usage of internal relays
One of their common uses is the case when a certain condition must be used in the operation
of more than one rung (network).
Basuwaqi, A. M 51
Internal relays
Usage of internal relays
Basuwaqi, A. M 52
Internal relays
Usage of internal relays
Basuwaqi, A. M 53
Set Reset Flip Flop
Introduction
S R Q
1 0 1
0 1 0
1 1 0
0 0 NO CHANGE
Basuwaqi, A. M 54
Reset Set Flip flop
Introduction
S R Q
1 0 1
0 1 0
1 1 1
0 0 NO CHANGE
Basuwaqi, A. M 55
Basuwaqi, A. M 56
DESIGNING SYSTEMS
Introduction
• How they and a PLC system can be tested and faults found.
Basuwaqi, A. M 57
DESIGNING SYSTEMS
Program development
Define
Sequence/
Inputs/ Instructions Test / debug Documentation
flow chart
outputs
Basuwaqi, A. M 58
DESIGNING SYSTEMS
Flow charts and pseudocode
Pseudocode is a written
translation of the code.
Basuwaqi, A. M 59
DESIGNING SYSTEMS
Sequential
the flow chart for when A or B is to happen if a particular condition X being YES or NO
occurs. The pseudocode to describe this involves the words IF-THEN-ELSE-ENDIF.
A loop is a repetition of some element of a program, the element being repeated as long as
some condition prevails
Basuwaqi, A. M 62
DESIGNING SYSTEMS
Looping
Basuwaqi, A. M 63
DESIGNING SYSTEMS
Looping
Basuwaqi, A. M 64
DESIGNING SYSTEMS
PLC systems and safety
• Modern safety legislation charges employers with duties which include making the
workplace safe and without risks to health and ensuring that plant and machinery are safe
and that safe systems of work are set and followed.
• Safety must be a priority in the design of a PLC system. Thus, emergency stop buttons and
safety guard switches must be hard wired and not depend on the PLC software for
implementation so that, in the situation where there is a failure of the stop switch or PLC,
the system is automatically safe. The system must be fail-safe
Basuwaqi, A. M 65
DESIGNING SYSTEMS
PLC systems and safety
Basuwaqi, A. M 66
DESIGNING SYSTEMS
PLC systems and safety
1. Power supply
2. PLC (programmable logic
controller)
3. Digital input cards
4. Digital output cards
5. Analog input cards
6. Transient surge protectors
7. Circuit breakers
8. Relay switches
9. Operator interface terminal
10. NEMA 12 enclosure
Basuwaqi, A. M 68
DESIGNING SYSTEMS EXERCISES
EXERCISE 1
Basuwaqi, A. M 69
DESIGNING SYSTEMS EXERCISES
EXERCISE 2
• DESIGN A PROGRAM to produce an on-off cycle timer. The timer is designed to switch
on an output for 5 s, then off for 5 s, then on for 5 s, then off for 5 s, and so on
• DESIGN A PROGRAM that could be used to flash a light on and off as long as there is
some output occurring
Basuwaqi, A. M 70
DESIGNING SYSTEMS EXERCISES
EXERCISE 3
Basuwaqi, A. M 71
DESIGNING SYSTEMS EXERCISES
EXERCISE 4
The process flow diagram illustrated in Figure. The sequential task is as follows:
1. Start button is pressed.
2. Table motor is started
3. Package moves to the position of the limit
switch and automatically stops. Other
auxiliary features include:
• a stop button that will stop the table, for any
reason, before the package reaches the limit
switch position;
• a red pilot light to indicate the table is
stopped; and
• a green pilot light to indicate the table is
running.
Basuwaqi, A. M 72
DESIGNING SYSTEMS EXERCISES
EXERCISE 5
Basuwaqi, A. M 73
DESIGNING SYSTEMS EXERCISES
EXERCISE 6
Figure shows the sketch of a continuous filling operation.
This process requires that boxes moving on a conveyor be
automatically positioned and filled. The sequence of
operation for the continuous filling operation is as follows:
• Start the conveyor when the start button is momentarily
pressed.
• Stop the conveyor when the stop button is momentarily
pressed.
• Energize the run status light when the process is
operating.
• Energize the standby status light when the process is
stopped.
• Stop the conveyor when the right edge of the box is
first sensed by the photo sensor.
• With the box in position and the conveyor stopped,
open the solenoid valve and allow the box to fill. Filling
should stop when the level sensor goes true.
• Energize the full light when the box is full. The full light
should remain energized until the box is moved clear Basuwaqi, A. M 74
of the photo sensor
DESIGNING SYSTEMS EXERCISES
EXERCISE 7
Filling/Drain Control operation
Basuwaqi, A. M 75
Basuwaqi, A. M 76