0% found this document useful (0 votes)
129 views76 pages

04 - Programming Continous

The document discusses different types of timers used in PLC programming including on-delay, off-delay, pulse, and cascaded timers. It provides examples of ladder logic diagrams using various timers to implement functions like sequencing, time delays, and flashing lights on and off for a set duration. The timers can be programmed using ladder logic rungs or functional block diagrams depending on the PLC manufacturer.

Uploaded by

Ahmed Bashnaini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views76 pages

04 - Programming Continous

The document discusses different types of timers used in PLC programming including on-delay, off-delay, pulse, and cascaded timers. It provides examples of ladder logic diagrams using various timers to implement functions like sequencing, time delays, and flashing lights on and off for a set duration. The timers can be programmed using ladder logic rungs or functional block diagrams depending on the PLC manufacturer.

Uploaded by

Ahmed Bashnaini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Basuwaqi, A.

M 1
PROGRAMMING OF PLC
Types of PLC Programming Language
Instruction List (IL) Structured text programming (ST)

Functional Block Diagram Programming (FBD) Ladder Diagram (LAD)

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.

A function often provided with PLCs is the conditional


jump. We can describe this as:

IF (some condition occurs) THEN


perform some instructions
ELSE
perform some other instructions.

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

Jumps within jumps are possible. For example, we


might have the situation If the condition for the
jump instruction 1 is realized then the program
jumps to rung 8.

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

With Allen-Bradley, subroutines are called by using


a jump-to subroutine JSR instruction, the start of
the subroutine being indicated by
SBR and its end and point of return to the main
program by RET

Basuwaqi, A. M 18
JUMP & CALL
Subroutines: Mitsubishi

Mitsubishi program, When input 1 occurs,


the subroutine P is called. This is then
executed, the instruction SRET indicating
its end and the point at which the program
returns to the main program. To clearly
indicate where the main program ends the
FEND instruction is used.

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

• Mechanical timing relays are used to


delay the opening or closing of contacts
for circuit control.

• The operation of a mechanical timing


relay is similar to that of a control relay,
except that certain of its contacts are
designed to operate at a preset time
interval, after the coil is energized or
de-energized

Basuwaqi, A. M 21
TIMERS
Treatment of timers

A common approach is to consider Some treat a timer as a delay block


timers to behave like relays

Basuwaqi, A. M 22
TIMERS
Types of timers
There are a number of different forms of timers that can be found with PLCs.

(a) (b) (c)

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

As an illustration of the use of an off-


delay timer, consider the Allen
Bradley program shown

The EN (for enable) contacts.


The TT (for timer timing) contacts.
The DN (for done) contacts which are
normally closed/open.

Basuwaqi, A. M 31
TIMERS
Off-delay timers

The EN (for enable) contacts.

The TT (for timer timing) contacts.

The DN (for done) contacts which are


normally closed/open,

Basuwaqi, A. M 32
TIMERS
Pulse timers

• Pulse timers are used to


produce a fixed duration
output from some initiating
input.

• a ladder diagram for a system


that will give an output from
Out 1 for a predetermined
fixed length of time when
there is an input to In 1, the
timer being one involving a
coil

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:

• we might have both timer 0 and timer 1 set


to 1 s.
• When the output occurs, then timer 0 starts
and switches on after 1 s.
• This closes the timer 0 contacts and starts
timer 1.
• This switches on after 1 s and, in doing so,
switches off timer 0.
• The lamp is only on when timer 0 is on.
Basuwaqi, A. M 34
TIMERS
Example 2 : traffic light (HW)

consider the sequencing of traffic lights to give the


sequence red only, red plus amber, green, amber,
then repeat itself. A simple system might just have
the sequence triggered by time, with each of the
possible states occurring in sequence for a fixed
amount of time

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

Coil-formatted up-counter instruction Coil-formatted counter and reset instructions

Basuwaqi, A. M 37
COUNTERS
Introduction

• A counter is set to some preset number


value and, when this value of input pulses
has been received, it will operate its
contacts. Thus normally open contacts
would be closed, normally closed contacts
opened.

• There are two types of counter:


1. Down-counters (CTD) count down from
the preset value to zero.
2. Up-counters (CTU) count from zero up to Block-formatted counter instruction
the preset value

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

Output when zero reached Output when set count


after counting down from set reached after counting up from
value zero

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

(a) Siemens, (b) Allen-Bradley counting program


Basuwaqi, A. M 43
COUNTERS
Example

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
Basuwaqi, A. M 44
COUNTERS
Example
When there is a pulse input to X400, both the
counters are reset. The input to X400 could be
the push button switch. The input which is
counted is X401. This might be an input from a
photocell sensor which detects the presence of
tins passing along the conveyor. 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. This
might be a solenoid which is used to activate a
deflector to deflect items into one box or
another. 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 Basuwaqi, A. M 45
COUNTERS
Up and down counting
(a) Using up- and down-counters, (b) Allen-Bradley program
It is possible to program up- and down-
counters together. Consider the task of
counting products as they enter a
conveyor line and as they leave it, or
perhaps cars as they enter a multi-storage
parking lot and as they leave it.

IEC 1131-3
standard symbol for
up/down counter

Basuwaqi, A. M 46
COUNTERS
Up and down counting

Up and down counting with


a Siemens PLC

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 “

• A certain number of coils allowed to be programmed in SIMATIC S7 software which


is 2048 internal relay or more

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

Example of internal relays uses; for long network

Basuwaqi, A. M 52
Internal relays
Usage of internal relays

Another example of internal relays uses ; The

conveyor belt of the Buffering station will starts

only if "Start" push button is pressed twice and will

stop when "Stop“ push button is pressed.

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

This chapter considers:

• How programs are designed and

• How they and a PLC system can be tested and faults found.

This involves consideration of both the hardware and the software.

Basuwaqi, A. M 57
DESIGNING SYSTEMS
Program development

Whatever the language in which a program is to be written, a systematic approach to the


problem can improve the chance of high quality programs being generated in as short a
time as possible.

Define
Sequence/
Inputs/ Instructions Test / debug Documentation
flow chart
outputs

Basuwaqi, A. M 58
DESIGNING SYSTEMS
Flow charts and pseudocode

(a) Flow chart symbols, and


shapes

(b) example of a simple flow chart

Pseudocode is a written
translation of the code.

Basuwaqi, A. M 59
DESIGNING SYSTEMS
Sequential

Consider a sequence when event A has to be followed by event B.

(a) Flow Chart, (b) LAD, (c) SFC Basuwaqi, A. M 60


DESIGNING SYSTEMS
Conditional

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) Flow Chart, (b) LAD, (c) SFC Pseu.Co


Basuwaqi, A. M 61
DESIGNING SYSTEMS
Looping

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

In pseudocode this can be represented by


using the words
WHILE-DO -ENDWHILE

Basuwaqi, A. M 63
DESIGNING SYSTEMS
Looping

Where a loop has to be repeated for a


particular number of times, a counter can
be used, receiving an input pulse each
time a loop occurs and switching out of
the loop sequence when the required
number of loops has been completed

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.

• An important standard is IEC (International Electrotechnical Commission) 61508:


Functional safety of electrical/electronic/ programmable electronic safety-related systems.
The standard is in seven parts.

• 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

An unsafe stop system

A safe stop system

Basuwaqi, A. M 66
DESIGNING SYSTEMS
PLC systems and safety

*For a safe emergency stop system


we need one which will provide a
stop signal if there is a fault and the
switch cannot be operated

An unsafe emergency stop system

A safer emergency stop system


Basuwaqi, A. M 67
DESIGNING SYSTEMS
PLC Enclosure

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

consider the simple process control problem


illustrated in the figure Here a mixer motor
is to be used to automatically stir the liquid
in a vat when the temperature and pressure
reach preset values.

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 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

• 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

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

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

Figure shows the sketch of a drilling process that


requires the drill press to turn on only if there is a part
present and the operator has one hand on each of the
start switches. This precaution will ensure that the
operator’s hands are not in the way of the drill.
The sequence of operation requires that switches
1 and 2 and the part sensor all be activated to make
the drill motor operate.

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

You might also like