Programable Logic controller questions 1-3
MODULE TITLE: PROGRAMMABLE LOGIC CONTROLLERS
TOPIC TITLE: PROGRAMMABLE FACILITIES
LESSON 2: TIMERS AND COUNTERS
PLC - 6 - 2
© Teesside University 2011
Published by Teesside University Open Learning (Engineering)
School of Science & Engineering
Teesside University
Tees Valley, UK
TS1 3BA
+44 (0)1642 342740
All rights reserved. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted, in any form or by any means, electronic, mechanical,
photocopying, recording or otherwise without the prior permission
of the Copyright owner.
This book is sold subject to the condition that it shall not, by way of trade or
otherwise, be lent, re-sold, hired out or otherwise circulated without the publisher's
prior consent in any form of binding or cover other than that in which it is
published and without a similar condition including this
condition being imposed on the subsequent purchaser.
________________________________________________________________________________________
INTRODUCTION ________________________________________________________________________________________
The main object of this lesson is to provide the general basis for attempting
slightly more ambitious programming exercises. This is achieved by
incorporating into the ladder diagrams devices such as timers, counters and
combinations of the two. The use of timers allows what would otherwise be a
spontaneous on/off set of characteristics, to become a controlled sequence
occurring in a predictable fashion.
The challenge in designing, reading and understanding ladder diagrams for
specific applications does not, therefore, merely rest at the Boolean logic level.
To be "good" at applications, programmers need to possess intimate knowledge
of the behaviour of their machine's functions. They also need to remember the
historical state of the devices included within the ladder diagram.
________________________________________________________________________________________
YOUR AIMS ________________________________________________________________________________________
On completing this lesson you should be able to:
• relate a written algorithm to the ladder diagram which will satisfy its
requirements
• follow the operation of timer/timer combinations
• understand typical operation of counters used in PLCs
• analyse more complex ladder diagrams to determine correct
operation
• devise suitable ladder diagrams to fulfil operational specifications.
1
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
CIRCUIT APPLICATIONS OF TIMERS ________________________________________________________________________________________
In the previous lesson of this topic, ladder diagram programming and the
operation of PLC timers were introduced. Brief mention was also made of the
requirements of part of a pelican crossing control circuit. At this stage the
circuit for the crossing can be expanded and improved by the addition of some
timers.
The following is a description of the required operation – note that a flashing
amber light is not included at this time.
When a pedestrian pushes the button the PLC must remember the event as well
as lighting up the WAIT sign. A check of the road sensors begins in order to
determine whether a vehicle is passing. The road sensors are to be checked
over a five second period. If no vehicle is sensed within this time then the road
lights can be taken through the light change sequence. If, on the other hand, a
vehicle is sensed then a further five seconds must elapse whilst the check is
made again.
The "normal" lighting requirement is that the GREEN road traffic light and the
RED man light should be on. The lights must return to this set of conditions
after the sequence change has been run through once.
The input designations will be:
X001 for the pedestrian push switch
X004 for the road traffic sensor.
The output designations will be:
Y000 for the red man light
Y001 for the green man light
Y004 for the wait sign
Y005 for the amber road light
2
Teesside University Open Learning (Engineering)
© Teesside University 2011
Y006 for the red road light
Y007 for the green road light.
The required light change sequence can be represented on the chart below.
The points to note from the chart are:
(a) The chart is broken up into six time change periods. The conditions in
time period 1 are the same as in time period 6 and are to be regarded as
the "normal" conditions.
(b) The red man light and the green man light are always in opposite states.
(c) Each of the red and green road lights has only one on and one off state
during the sequence.
(d) The amber road light has two changes of state during the sequence. This
means that two sets of conditions must bring on this output. One set of
conditions OR a second set of conditions i.e. the amber light output rung
in the ladder diagram is likely to possess an OR statement.
TIME CHANGE PERIODS
Green road light
Amber road light
Red road light
Red man
Green man
Wait sign
1
on
off
off
on
off
off
2
on
off
off
on
off
on
3
off
on
off
on
off
on
4
off
off
on
off
on
off
5
off
on
on
off
on
off
6
on
off
off
on
off
off
* see note (d)
3
Teesside University Open Learning (Engineering)
© Teesside University 2011
Other constraints are:
The change from period 2 to period 3 can only be made after at least one five
second check of the road sensors.
The conditions in period 3 should last for only four seconds before changing to
those of period 4.
The conditions in period 4 should last for ten seconds.
The conditions in period 5 should last for three seconds.
Specifying four distinct time durations tends to indicate the need for four
timers.
A ladder diagram for this sequence can now be examined. It must be
remembered that, as was shown in the previous lesson, many solutions to this
problem are likely to work. The one provided in this lesson is not necessarily
the best solution. It has been constructed and tested in a way which allows it
to be broken down into simple sections which can be recognised from previous
work. The explanation of the operation of the diagram is, unfortunately, long
and drawn out but you should follow it by examining the diagram as the
sequence is analysed.
The ladder diagram of the pelican crossing is shown in FIGURE 1.
4
Teesside University Open Learning (Engineering)
© Teesside University 2011
FIG. 1
TIM00 (5 secs) X004
Y005 Y007
Y006
R002
Y005
Y006 Y001Y000
TIM03
R003
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
X001 R000
R000
R004
R000
Y004
Y006 Y004
R000
TIM00
R001
R003 R001
Y005
Y007 Y001 Y000
R001 Y006 Y005
TIM01
Y006
TIM01 (4 secs)
R003 Y006
Y006 R003 TIM02 (10 secs)
TIM02
R002
R003 R002
R002 TIM03 (3 secs)
R003Y000
Y007
Y001 R004Y006
WAIT SIGN
GREEN LIGHT
RED MAN
AMBER LIGHT
RED LIGHT
GREEN MAN
Y005
5
Teesside University Open Learning (Engineering)
© Teesside University 2011
You may be able to follow the diagram of FIGURE 1 without the need for an
explanation. However, for those who can't, and for the sake of completeness,
we shall analyse this diagram by working down from top to bottom checking
through each rung as we go.
Before doing this in great detail just take a few moments to scan the diagram to
note that none of the rungs is, in any way, more complicated than those
examined in other lessons. So understanding the circuit operation should
present no real problems.
In this analysis we shall assume that every "normal" state of circuit elements
applies unless we have information to the contrary. Hence, if we come to, say,
a N/C set of contacts we assume that they are closed unless we definitely know
otherwise.
Rung one consists of a simple latch (which is used frequently throughout the
circuit). When the pedestrian presses the push switch X001 closes and because
R004 is assumed closed the R000 relay will switch on. Once on, all R000
contacts will change state. The first of these sets of contacts is a N/O set in
rung one. The closing of these holds the R000 relay in the on state. If the
pedestrian now releases the push the R000 relay will not switch off.
In the second rung the closing of the R000 contacts switches on the Y004
physical output (the N/C Y006 contacts assumed closed) to which is connected
the WAIT sign.
The lighting up of the wait sign signals recognition to the pedestrian of the
switch having been pressed.
In the third rung the closing of the R000 contacts enables the first timer to
begin the five second check for the passage of a road vehicle. If a vehicle is
detected then the N/C contacts of X004 input will open and immediately
6
Teesside University Open Learning (Engineering)
© Teesside University 2011
disable the timer. The timer value (representing five seconds) will be reloaded
into the timer so that the timing can begin again after the vehicle has passed. If
no vehicle is sensed within the five seconds the timer output will switch on.
In rung four, the closing of the TIM00 contacts switches on the R001 memory
relay (the N/C R003 contacts assumed closed). The R001 relay will now be
latched on by the R001 contacts connected, in parallel, across the TIM00
contacts. This arrangement ensures that the five second check is completed
and is remembered. If a vehicle subsequently passes the road sensor the
TIM00 timer will be disabled but this will have no effect on the R001 relay.
The fifth rung represents an unbroken path to switch on the Y007 output. This
output controls the green road light which is required to be "normally" on.
Y007 would be off if either of Y005 or Y006 outputs were on but at this point
in time we have not proved this.
In rung six two possible paths exist for the switching on of the Y000 output.
This output supplies the red man indicator which should "normally" be on and
therefore in rung six the Y007 contacts will be closed to bring on the Y000
(red man) output.
After reading the first six of the fifteen rungs we can pause to assess the
situation.
Rungs five and six proved that the green road light and the red man would
normally be on. Rungs one and two prove that the pressing of the push can be
recognised and remembered. Rungs three and four show that a five second
check can be made and that the system will remember having made the check.
We can now continue with the analysis.
The seventh rung presents two possible paths for the switching on of the output
which controls the amber road light (Y005). Both of these paths are
"normally" open circuits and so the amber light is normally off. In one of the
7
Teesside University Open Learning (Engineering)
© Teesside University 2011
paths, however, the R001 contacts could be complete, as we have already
shown by the proving of rung four. Therefore, if the pedestrian presses the
push, the wait sign illuminates and if no vehicle is detected for a five second
period then the amber road light (Y005) will come on.
This also means that the N/C Y005 contacts in rung five will open, thus
extinguishing the green road light (Y007). The loss of Y007 would switch off
the red man output too early and so the parallel connected Y005 contacts
across the Y007 contacts in rung six take over this task.
We have now completed the move through the sequence from period 1 to
period 2 and on to period 3.
The red man is still on but the green road light has gone off so that the amber
can come on.
When the amber light comes on the Y005 contacts in rung eight close to
enable the second timer TIM01. This timer is set with a value of four seconds
after which time all TIM01 contacts will change state.
In rung nine, we have the only set of TIM01 contacts in the diagram. When
these close the Y006 output (red road light) will come on and stay on by its
own latching contacts Y006 across the TIM01 contacts.
There are many sets of Y006 contacts used in the diagram.
In rung two the N/C Y006 contacts open to unlatch the Y004 (wait sign)
output.
In rung seven the loss of the Y006 contacts will cause the loss of the amber
road light (Y005). With the loss of Y005 in rung five the green road light
would come back on; however, the series connected N/C Y006 contacts keep
the green light off.
8
Teesside University Open Learning (Engineering)
© Teesside University 2011
With the switching off of both Y005 and Y007 rung six can no longer retain
the Y000 (red man) in the on state.
So, at rung ten, Y006 is closed and Y000 is not on, therefore the Y001 (green
man) output will come on to replace the loss of the red man.
The last Y006 contacts to mention at this stage are in rung eleven. These
enable the timer TIM02. While this timer is timing out no other changes are
made.
We are now in the conditions of period 4.
After the ten seconds of the TIM02 timer have elapsed the TIM02 contacts in
rung 12 will close. This allows R002 to switch and latch itself on.
In rung seven, the closing of the N/O parallel connected R002 contacts brings
the Y005 (amber road light) on for the second time. (Remember the mention
on page 3 about the likely ORed conditions.) The green man, red road light
and the amber road light are all on at this time. We are, therefore, in time
period 5.
The closing of the R002 contacts in rung thirteen enables the last timer TIM03.
After three seconds TIM03 output comes on to cause the R003 relay to switch
on. This relay is being used as a memory latch so that the system knows that
the red and amber road light combination has been on for three seconds.
The four sets of N/C R003 contacts within the diagram all open causing:
• the resetting of TIM02 (rung eleven)
• the unlatching of relays R001 and R002 (rungs four and twelve) thus
turning off the amber road light Y005 (rung seven)
9
Teesside University Open Learning (Engineering)
© Teesside University 2011
• the switching off of Y006 (the red road light) in rung nine, which in
turn causes the green man to go off (rung ten).
The loss of Y005 and Y006 restores Y007, the green road light (rung five).
Rung fifteen is a reset for the R000 relay. R004, the resetting element, will
switch on only when Y001, Y005 and Y006 are all on. This condition arises in
period 5 and ensures that the sequence will only run once (because R000 is
disabled) before the next five second check is carried out. This lockout effect
ensures that someone continuing to press the push does not cause the sequence
to freeze and that a new push press can only be accepted after the sequence is
virtually complete.
You should notice that, certainly at the beginning of the ladder diagram, there
was a relationship between working from the top of the diagram and the
requirements of the start of the sequence. The sequence was executed as we
worked our way down through the diagram. In this case the diagram does
not need to be presented in this way for it to work correctly, i.e. rung
seven could have been placed first instead of rung one, followed (say) by
rung ten, etc., etc. As long as all rungs were in the diagram somewhere it
would have worked. This is not, unfortunately, always the case and problems
can arise due to incorrect rung positioning.
Any unnecessary jumbling up of the rungs makes the diagram that much more
difficult for someone to read. That someone may be you at some time in the
future!
10
Teesside University Open Learning (Engineering)
© Teesside University 2011
TIMER/TIMER COMBINATIONS
Perhaps the diagram of FIGURE 1 could be improved even further by the
addition of a flashing amber output. One method used to obtain such action
requires the use of a further two timers. These two timers would need to be
arranged so that they worked together to produce a regular on/off switching
operation to drive a physical output. Suppose a selected output, say Y003, was
required to be switched on for five seconds then switched off for ten seconds
before being switched on again to recommence the five seconds on/ten seconds
off freerunning operation. The on/off/on sequence will be initiated and
maintained by the closing of input X006. The two timers will be identified as
TIM04 and TIM05. In Lesson 1 we looked at the operation of both a delay-in-
on timer and a delay-in-off timer. This problem effectively requires one of
each of these; one to delay the output from switching off (i.e. keep it switched
on for five seconds) and the other to delay the output from switching on (i.e.
keep it switched off for ten seconds).
The ladder diagram of FIGURE 2 can now be examined.
FIG. 2
TIM04
X006 TIM05 TIM04 5 seconds
TIM05 10 seconds
1
2
3
Y003X006 TIM04
11
Teesside University Open Learning (Engineering)
© Teesside University 2011
The X006 input contacts in rungs one and two are the enable/disable operation
control elements. If rung one is examined first then when input X006 contacts
close the Y003 output will switch on (the N/C TIM04 contacts are assumed to
be closed).
In rung two the X006 contacts are closed to enable timer TIM04 to begin
timing.
Rung three is presently under open circuit conditions.
When the Y003 output has been on for five seconds the TIM04 output will
switch on. All TIM04 contacts will change state.
In rung one the N/C TIM04 contacts will open switching off the Y003 output.
In rung three the N/O TIM04 contacts will close to enable the second timer
TIM05.
When the Y003 output has been off for ten seconds the TIM05 output will
switch on. All TIM05 contacts will change state.
In rung two the N/C TIM05 contacts will open to disable the TIM04 timer. All
TIM04 contacts will then change back to their original "normal" state. Output
Y003 will switch on again and the TIM04 contacts in rung three will now
disable the TIM05 timer.
TIM05 output is therefore on for a very short duration. It switches off
microseconds after it was switched on.
FIGURE 3 shows the timing diagram for the arrangement.
12
Teesside University Open Learning (Engineering)
© Teesside University 2011
FIG. 3
We will now leave the application of timers for the time being but you will
need to remember the work we have covered for future programming tasks.
Closed X006
Y003 On
TIM04 output
TIM05 output
Time axis
Off
1 second time periods
Small duration pulse
X006 contacts
open
Open
13
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
COUNTERS ________________________________________________________________________________________
Counters are undoubtedly a valuable addition to any control system. In
everyday life we tend to take counters for granted. In a car, for instance, a
counter (the mileometer) is used to keep a record of the number of miles the
vehicle has travelled i.e. it is a mile counter. In the filling station the fuel
pumps count how many litres of fuel are put into a tank. In the home an audio
or video cassette recorder uses a counter to locate a specific position on the
tape. These, and many others, are everyday examples of counters in use.
Quite often, someone may say something such as "my vehicle has clocked up
80 000 miles" when really they should say that the vehicle mile counter has
counted 80 000. This association between clocks and counters seems to stem
from the construction of the original counters, the rows of cogs in the
mechanical manufacture being reminiscent of clockwork mechanisms.
Of course mechanical counters are quite acceptable in certain applications
especially when the display dials are required to accompany the mechanism.
If, however, a remote indication is necessary then the linkage medium between
the event and the display may present major problems. Additionally the
maximum speed of mechanical counters may not match the requirements of
the application. Electronic counters, on the other hand, can cope with the
remote requirements quite easily and can have very high maximum speeds.
The possible disadvantages are that they may, in certain circumstances, be
more expensive and they do require a supply of electricity.
Counters incorporated into PLCs may utilize counter integrated circuits. In
fact the same I.C. may also house the timers. To be able to use the counters
does not, however, mean that the user needs to know anything about this
hardware because the programming software makes all the necessary
arrangements.
14
Teesside University Open Learning (Engineering)
© Teesside University 2011
Reasonably high counting speeds can be achieved, limited mainly by the scan
time of the software. Where a PLC has separate counter input terminals count
speeds of 2000 Hz (2000 count pulse events per second) are quite realistic –
mechanical counters may be hard pushed to match such count rates.
PLC COUNTERS
Counters within PLCs are used to count specific events and compare the
number of events with a preset value specified by the program listing. The
preset value is often copied from the program listing and held in a specified
RAM location which is reserved with that counter's identity. When the count
event takes place the preset value, held in the counter, is decremented (i.e.
decreased) by subtracting one. Immediately after the decrementing operation
the value is checked to see if it has decreased to zero. If it has then the count is
complete and the counter output switches on. At which point all contacts
within the program, which carry that counter's identity, will switch i.e. N/O
counter contacts will close and N/C counter contacts will open. The counting
sequence can be interrupted and the preset value reinstated back into the
counter at any time by the application of a RESET condition.
A PLC may possess several counters so each must be identified to ensure that
the software handles the correct one.
Generally speaking there are four items which are required to be specified for
each counter being used:
(a) the event which is to be counted
(b) the identity of the counter being used
(c) the number of counts to be made before the counter output switches on
(d) the RESET (or DISABLE) conditions.
15
Teesside University Open Learning (Engineering)
© Teesside University 2011
The method used to represent counters on a ladder diagram and the
programming syntax used vary from manufacturer to manufacturer, as does the
counter operation. Here again the warning must be given to would-be users to
check the manual before assuming the type of operation.
FIGURE 4 shows a section of a ladder diagram which we can use as an
example to describe typical operation.
FIG. 4
In all cases of using counters the manufacturer's manual must be used to ensure
that the elements are specified in the correct order.
R059
X006
X001 R023
CNT2
Count input
CNT2
10 counts
Reset input
Y002
16
Teesside University Open Learning (Engineering)
© Teesside University 2011
The program listing for the above extract would be:
STEP OP CODE OPERAND
020 LD X001 021 AND R023
022 LD X006 023 OR R059
024 CNT2 010 counter identiity and preset value
025 LD CNT2 026 OUT Y002
We can now attempt to clarify the operation of the diagram of FIGURE 4.
A quick look at the diagram shows that each rung is in the open circuit
condition if the assumed "normal" conditions apply.
We'll start the explanation at rung two. This rung is the reset input for the
counter. A circuit is made if either X006 OR R059 is closed. Either of these
will cause the counter to reset back to its preset value (10 in this case). If
either input contacts X006 or memory relay contacts R059 close the counter
value is reset. Both of these sets of contacts must be opened before the counter
is enabled to count. Assuming then that the counter is reset and enabled we
can turn our attention to rung one.
Rung one contains the count input conditions. In the diagram these conditions
are X001 AND R023. This means that if both of these contacts are closed at
the same time the input will recognise this as a count event. Recognition of the
event is "edge sensitive" to ensure that only one count will be made. The term
edge sensitive can be best illustrated by the use of a timing diagram
(FIGURE 5).
a physical output driven by the counter outpuut{
specification for the reset conditions{
specification for the input count event{
17
Teesside University Open Learning (Engineering)
© Teesside University 2011
FIG. 5
Therefore, each time R023 ANDed with X001 are newly closed the
recognition of a count event is made and the counter value is decremented.
After ten count events (in this case), assuming that the reset line has not been
enabled, the counter (CNT2) output will switch on. In the diagram of FIGURE
4 this means that the N/O CNT2 contacts in rung 3 will close and physical
output Y002 will switch on. Any further count events will not be recognised
while the counter output is switched on.
If now, or at any time, either X006 or R059 contacts are closed then the count
value reverts back to ten and, because it is no longer zero, the counter output
will switch off. In our circuit this means that output Y002 will also switch off.
As with relays and timers any number of counter contacts can be included
within a ladder diagram.
R059 Open
X006
X001
R023
Closed
Open
Open
Counter value
Counter enabled
Leading edge recognised
Time axis
10 10 9 9 8 8 7
Reset
X001 AND R023
Open
18
Teesside University Open Learning (Engineering)
© Teesside University 2011
A further point to remember is that the counter reset input normally has
precedence over the count up input i.e. if the reset line is enabled then no count
events will be recognised.
COUNTER VARIATIONS
What has been described so far about counters holds true for a number of
PLCs. However, the reader should understand that, as mentioned earlier, the
manufacturer's manual should be checked because variations do exist between
manufacturers.
This section of the lesson gives some indication of the extent of that variation.
In some cases the counter operation is not that of a down counter i.e.
decrementing to zero, but is instead that of an up counter. This means that
after reset and when enabled, the counter begins at zero and increments with
every input count event until the counter value equals the preset value, at
which time the counter output switches on.
In other cases the counter operation may be that of a ring counter. This counts
up from zero (after having been reset) to the preset value before turning the
output on, but then continues to recognise further count events which causes
the counter value to spill over back to zero before starting the count again. The
output remains on only while the counter value is the same as the preset value.
Yet a further variation can be an up/down counter. Such a counter has an up
count input and a separate down count input. When the counter is enabled a
suitable signal on either input makes the counter either increment or decrement
the count value. As with the previous counter the output switches on when the
count value equals the preset value. A very graphic description of the use of
such a counter would be in the control of the number of vehicles allowed to
enter a multistorey car park. If, for example, the car park had space for
19
Teesside University Open Learning (Engineering)
© Teesside University 2011
five hundred vehicles then an up/down counter could be used to count them in
and illuminate a CAR PARK FULL sign when five hundred have entered.
Should a vehicle leave by the exit then the count would be decremented and
the sign turned off.
In other types of counters, typically high speed types, multiple outputs may be
possible. The multioutputs do not normally drive physical outputs but will
control internal relays which can switch on or off the physical outputs.
Outputs from such counters are fully programmable by having two count
values specified. When the counter reaches the first value an output will
switch on and the counter will continue to recognise input count signals until a
second value is reached. At this time the counter output will switch off.
Couple this with the fact that the counter may be able to simultaneously
control numerous different outputs, all with different values, and you may
begin to appreciate how powerful this counter is.
Another variation relates to the operation of the reset line. Sometimes the reset
line must have its contacts held closed before the counter will be enabled. If
the reset line is opened at any time then the counter resets. This operation of
the reset line is the opposite of that explained earlier.
Hopefully, by now, you will appreciate the advice directing users to consult the
manufacturer's manual before launching into the use of counters.
20
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
TIMER/COUNTER CASCADES ________________________________________________________________________________________
PLC manufacturers are faced with the problem of deciding values for both the
timing increments and the maximum value which a timer (or counter) will
accept.
The maximum value may well be dictated by the word size of the processor
used. For example, a value of between 0 and 255 (00 to FF Hex) is
understandably common for eight bit processors. Another common range is 0
to 99 where binary coded decimal (BCD) codes are employed. These two
number ranges fit quite readily into the number handling techniques used by
software engineers.
The problem of the value of the timing increments may seem a little more
arbitrary. When previously mentioning timers the incremental values of 0.1
second and 1 second were stated as common values but when these time values
are used with the maximum timer range the total time period seems very
limited. For example, a timer value of, say, 255 with a time increment of
0.1 second only spans a total time of 25.5 seconds. Even if a 1 second time
interval used the time span only increases to 255 seconds (4 minutes
15 seconds).
For many applications this fine control of small timed periods will be
excellent. A flexible manufacturing system, for example, where a conveyor
carries items from operation to operation may require an operation to be
carried out within, say, 5.5 seconds if the expected production rate is to be
maintained.
For other applications, however, such small values of time could be totally
inadequate. For example, a furnace may be allowed 45 minutes to heat soak an
ingot of metal before a rolling operation commences. Clearly 255 seconds
would not suffice.
21
Teesside University Open Learning (Engineering)
© Teesside University 2011
PLC manufacturers want to be able to claim that their PLC will be suitable for
any control application and need, therefore, to ensure that as many different
possibilities in programming exist without additional accessories being
required.
For this reason the timers are made with small time increments to be able to
handle the fine timing problems and yet they can be expanded by the use of a
timer/counter combination to obtain much larger timed periods.
Consider what most people would do if they were given a stop watch which
only timed up to one minute and were asked to time a five minute period. The
majority would break up this time period into five one minute intervals. After
each one minute they would add one to a count until their count value was five
and the time was up. The very same idea can be applied to timing operations
controlled by the PLC. For example, a timer set for 60 seconds could have its
output recognised and counted before being reset to time again. When the
counter reaches five then the counter output, and not the timer output, would
signal the end of the five minute period. The circuit of FIGURE 6 illustrates
this arrangement.
FIG. 6
X002
TIM02
X004 TIM02
CNT1
CNT1
5 counts
Y002
TIM02
60 seconds
Count
Reset
22
Teesside University Open Learning (Engineering)
© Teesside University 2011
CIRCUIT OPERATION
In the diagram of FIGURE 6 all rungs are in the open circuit condition if the
"normal" state of each element is assumed. To reset the counter the X002
contacts will need to be closed and then opened to enable the count inputs to
be recognised. If we assume that this is the case then a starting point for
analysis purposes is established.
The only other set of input contacts is X004. If these contacts are closed and
are left closed then the TIM02 timer will be enabled to begin timing out. After
sixty seconds the timer output will switch on causing all TIM02 contacts to
change state. In the second rung the N/O TIM02 contacts will close to apply a
signal to the count input. The counter will, therefore, recognise the first 60
second time interval. In the first rung the N/C TIM02 contacts will open to
disable the timer and cause its output to switch off. Once off, the timer
contacts will revert to the normal state. The timer will be enabled to begin the
next 60 second time interval and the counter input will be open circuit once
again.
The operation of the timer is therefore as follows. Timing for sixty seconds,
switching its output on, then resetting itself after a very short time duration.
The actual on-time is dependent upon the scan time of the program pass. Each
occasion of the timer output switching on is recognised by the counter as a
count event. After five occurrences the counter output will switch on.
In the last rung the counter output is being used to drive physical output Y002.
The total arrangement, therefore, produces a delay in Y002 switching on of
five minutes after the closing of input X004 (provided that this input remains
closed for the whole period).
23
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
COUNTER/COUNTER CASCADES ________________________________________________________________________________________
Having appreciated that some maximum value is stated for the operation of
timers then it should be apparent that the same reasoning applies to counters.
Maximum counts of 99 or 255 are common. Inevitably the problem must arise
which requires a count in excess of the maximum value of the counter.
Consider as an example a programmable controller used to control a coil
winding machine which is required to count 1920 turns of enamelled copper
wire onto a winding former. In such cases the total number of counts would
need to be examined to ascertain whether it is a number which is the product of
two other values. If it is, then the total count may be obtained by simply
cascading two counters i.e. having one counter counting the events as they are
happening and having a second counter counting the number of times the first
counter produces an output. The output from the first counter must be reset
before the next input event arrives so that the correct total number of events are
recorded. The total count will be deemed to have occurred when the second
counter produces an output.
In the example above the number specified (1920) fits very nicely into this
category. The two counter values may be chosen such that the product is 1920.
In this application the first counter value may also be required for the control
of an intermediate operation within the coil winding procedure (the application
of inter-layer insulation for example). The counter values may not, therefore,
be arbitrarily taken from a product table if such conditions apply. The table
below indicates some of the possible values.
24
Teesside University Open Learning (Engineering)
© Teesside University 2011
COUNTER 1 COUNTER 2 PRODUCT
VALUE VALUE
240 8 1920
192 10 1920
160 12 1920
120 16 1920
80 24 1920
Clearly not all numbers are the product of two others which means that a
slightly different solution sometimes needs to be found.
FIGURE 7 shows a ladder diagram having two counters cascaded to produce
the 1920 count required for the previous example. The chosen values are 120
for the first counter and 16 for the second.
25
Teesside University Open Learning (Engineering)
© Teesside University 2011
FIG. 7
Check through the ladder diagram to determine the operational sequence. The
Self-Assessment Questions on page 28 will examine your understanding.
001
MR000
000
CNT0
MR001
MR000
002MR000 CNT0
001 is push switch to start motor
000 is stop motor input
002 is the revolution sensor pick-up input
120 counts
MR000
OUT 020
CNT0
MR001
CNT1
MR000
OUT 021
CNT1
MR001
16 counts
Output to coil winder motor
Output to release the coil winder motor brake
26
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
NOTES ________________________________________________________________________________________
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
....................................................................................................................................................
27
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
SELF-ASSESSMENT QUESTIONS ________________________________________________________________________________________
1. With reference to the diagram of FIGURE 7 answer the following
questions.
(a) Which rung of the diagram is used to 'remember' the operation of the
start motor push switch?
(b) What causes counter CNT1 to recognise a count input and hence
decrement its counter value?
(c) When does the coil winder motor switch on?
(d) When should the coil winder brake be on?
(e) Explain what you think happens when 1920 revolutions have been
detected.
2. Design a ladder diagram circuit which will fulfil the following
specification.
With the application of a momentary switch closure an output from the
PLC is to come on. After 3 seconds this output is to switch off and a
second output switch on for a further period of 6 seconds before it
switches off.
When the second output switches off the first output must switch back on
to begin the repeat of the 3 second on/6 second off operation.
When the second output switches off for the fourth time the sequence is
considered complete and both outputs remain switched off until the next
28
Teesside University Open Learning (Engineering)
© Teesside University 2011
momentary switch closure. FIGURE 8 shows the sequence in the form of
a timing diagram.
FIG. 8
Momentary input
First output
Second output
On
On
3 seconds
6 seconds
Off
Off
Time axis
29
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
ANSWERS TO SELF-ASSESSMENT QUESTIONS ________________________________________________________________________________________
1 (a) The pressing of the start switch is remembered by rung 1.
(b) A suitable logic state transition on the count input to CNT1 will
cause it to recognise a "count pulse". In the circuit of FIGURE 7 this
pulse is produced when counter CNT0 has an output.
(c) The coil winder motor switches on when memory relay MR000 is
switched on. This would normally happen as a consequence of input
contacts 001 being closed if input 000 and memory relay MR001 are
not on.
(d) The brake should be on whenever the motor is off. The brake should
be a spring applied/electrically released type to ensure that it is still
applied when the electrical supply is removed.
(e) After the second counter CNT1 has counted 16 inputs from the
output of CNT0, its output will switch on, bringing on memory relay
MR001.
MR001 resets memory relay MR000 which disables any further
counts, switches off the coil winder motor and applies the brake.
MR001 also resets counter CNT1.
Therefore, after 1920 turns the motor switches off, the brake is
applied and all counters are reset ready for the next coil winding
operation.
30
Teesside University Open Learning (Engineering)
© Teesside University 2011
2. There are many possible solutions to this sequence problem. The ladder
diagram of FIGURE 9 shows one version. Compare your solution with
FIGURE 9. If it is very different read FIGURE 9 to check that you can
follow it.
Points which you might note are:
(i) The momentary switch press is remembered by memory relay
MR030.
(ii) A normally closed stop switch has been included as input 000 in rung
1.
(iii) The start input, 001, is also being used to reset the counter at the
beginning of the sequence. This ensures that if the sequence is
stopped part way through, it will complete a full sequence the next
time it is run.
31
Teesside University Open Learning (Engineering)
© Teesside University 2011
FIG. 9
001
MR030
000
MR030
CNT0
MR030
TIM00
001 is momentary switch input
000 is a stop input
MR030 TIM00
TIM01
OUT 020
CNT0
TIM01
001
4 counts
CNT0
MR030 OUT 020
OUT 021
TIM01 6 secs
TIM00 3 secs
32
Teesside University Open Learning (Engineering)
© Teesside University 2011
________________________________________________________________________________________
SUMMARY ________________________________________________________________________________________
This lesson started as a continuation of Lesson 1 by introducing applications of
timers. The main example used was the control requirements of a partially
completed pelican crossing (more on this later).
The explanation of the ladder diagram operation was a little longwinded but if
you persevered the understanding of the operation will prove beneficial.
Generalisations were given which can be usefully incorporated into later
exercises.
The theory progressed to using two timers working together to produce an
on/off freerunning output. This arrangement is itself quite useful and can be
found in many applications.
The theme of the lesson changed to the discussion of counters and counter
variations before finishing off with timer/counter and counter/counter
cascades. The majority of the topics covered in this lesson are valid for PLCs
in general and form the basis of many modern control system requirements.
33
Teesside University Open Learning (Engineering)
© Teesside University 2011
<< /ASCII85EncodePages false /AllowTransparency false /AutoPositionEPSFiles true /AutoRotatePages /None /Binding /Left /CalGrayProfile (Dot Gain 20%) /CalRGBProfile (sRGB IEC61966-2.1) /CalCMYKProfile (U.S. Web Coated \050SWOP\051 v2) /sRGBProfile (sRGB IEC61966-2.1) /CannotEmbedFontPolicy /Error /CompatibilityLevel 1.4 /CompressObjects /Tags /CompressPages true /ConvertImagesToIndexed true /PassThroughJPEGImages true /CreateJDFFile false /CreateJobTicket false /DefaultRenderingIntent /Default /DetectBlends true /ColorConversionStrategy /LeaveColorUnchanged /DoThumbnails false /EmbedAllFonts true /EmbedJobOptions true /DSCReportingLevel 0 /SyntheticBoldness 1.00 /EmitDSCWarnings false /EndPage -1 /ImageMemory 1048576 /LockDistillerParams false /MaxSubsetPct 100 /Optimize true /OPM 1 /ParseDSCComments true /ParseDSCCommentsForDocInfo true /PreserveCopyPage true /PreserveEPSInfo true /PreserveHalftoneInfo false /PreserveOPIComments false /PreserveOverprintSettings true /StartPage 1 /SubsetFonts true /TransferFunctionInfo /Apply /UCRandBGInfo /Preserve /UsePrologue false /ColorSettingsFile () /AlwaysEmbed [ true ] /NeverEmbed [ true ] /AntiAliasColorImages false /DownsampleColorImages true /ColorImageDownsampleType /Bicubic /ColorImageResolution 300 /ColorImageDepth -1 /ColorImageDownsampleThreshold 1.50000 /EncodeColorImages true /ColorImageFilter /DCTEncode /AutoFilterColorImages true /ColorImageAutoFilterStrategy /JPEG /ColorACSImageDict << /QFactor 0.15 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> /ColorImageDict << /QFactor 0.15 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> /JPEG2000ColorACSImageDict << /TileWidth 256 /TileHeight 256 /Quality 30 >> /JPEG2000ColorImageDict << /TileWidth 256 /TileHeight 256 /Quality 30 >> /AntiAliasGrayImages false /DownsampleGrayImages true /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /GrayImageDepth -1 /GrayImageDownsampleThreshold 1.50000 /EncodeGrayImages true /GrayImageFilter /DCTEncode /AutoFilterGrayImages true /GrayImageAutoFilterStrategy /JPEG /GrayACSImageDict << /QFactor 0.15 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> /GrayImageDict << /QFactor 0.15 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> /JPEG2000GrayACSImageDict << /TileWidth 256 /TileHeight 256 /Quality 30 >> /JPEG2000GrayImageDict << /TileWidth 256 /TileHeight 256 /Quality 30 >> /AntiAliasMonoImages false /DownsampleMonoImages true /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /MonoImageDepth -1 /MonoImageDownsampleThreshold 1.50000 /EncodeMonoImages true /MonoImageFilter /CCITTFaxEncode /MonoImageDict << /K -1 >> /AllowPSXObjects false /PDFX1aCheck false /PDFX3Check false /PDFXCompliantPDFOnly false /PDFXNoTrimBoxError true /PDFXTrimBoxToMediaBoxOffset [ 0.00000 0.00000 0.00000 0.00000 ] /PDFXSetBleedBoxToMediaBox true /PDFXBleedBoxToTrimBoxOffset [ 0.00000 0.00000 0.00000 0.00000 ] /PDFXOutputIntentProfile () /PDFXOutputCondition () /PDFXRegistryName (http://www.color.org) /PDFXTrapped /Unknown /Description << /ENU (Use these settings to create PDF documents with higher image resolution for high quality pre-press printing. The PDF documents can be opened with Acrobat and Reader 5.0 and later. These settings require font embedding.) /JPN <FEFF3053306e8a2d5b9a306f30019ad889e350cf5ea6753b50cf3092542b308030d730ea30d730ec30b9537052377528306e00200050004400460020658766f830924f5c62103059308b3068304d306b4f7f75283057307e305930023053306e8a2d5b9a30674f5c62103057305f00200050004400460020658766f8306f0020004100630072006f0062006100740020304a30883073002000520065006100640065007200200035002e003000204ee5964d30678868793a3067304d307e305930023053306e8a2d5b9a306b306f30d530a930f330c8306e57cb30818fbc307f304c5fc59808306730593002> /FRA <FEFF004f007000740069006f006e007300200070006f0075007200200063007200e900650072002000640065007300200064006f00630075006d0065006e00740073002000500044004600200064006f007400e900730020006400270075006e00650020007200e90073006f006c007500740069006f006e002000e9006c0065007600e9006500200070006f0075007200200075006e00650020007100750061006c0069007400e90020006400270069006d007000720065007300730069006f006e00200070007200e9007000720065007300730065002e0020005500740069006c006900730065007a0020004100630072006f0062006100740020006f00750020005200650061006400650072002c002000760065007200730069006f006e00200035002e00300020006f007500200075006c007400e9007200690065007500720065002c00200070006f007500720020006c006500730020006f00750076007200690072002e0020004c00270069006e0063006f00720070006f0072006100740069006f006e002000640065007300200070006f006c0069006300650073002000650073007400200072006500710075006900730065002e> /DEU <FEFF00560065007200770065006e00640065006e0020005300690065002000640069006500730065002000450069006e007300740065006c006c0075006e00670065006e0020007a0075006d002000450072007300740065006c006c0065006e00200076006f006e0020005000440046002d0044006f006b0075006d0065006e00740065006e0020006d00690074002000650069006e006500720020006800f60068006500720065006e002000420069006c0064006100750066006c00f600730075006e0067002c00200075006d002000650069006e00650020007100750061006c00690074006100740069007600200068006f006300680077006500720074006900670065002000410075007300670061006200650020006600fc0072002000640069006500200044007200750063006b0076006f0072007300740075006600650020007a0075002000650072007a00690065006c0065006e002e00200044006900650020005000440046002d0044006f006b0075006d0065006e007400650020006b00f6006e006e0065006e0020006d006900740020004100630072006f0062006100740020006f0064006500720020006d00690074002000640065006d002000520065006100640065007200200035002e003000200075006e00640020006800f600680065007200200067006500f600660066006e00650074002000770065007200640065006e002e00200042006500690020006400690065007300650072002000450069006e007300740065006c006c0075006e00670020006900730074002000650069006e00650020005300630068007200690066007400650069006e00620065007400740075006e00670020006500720066006f0072006400650072006c006900630068002e> /PTB <FEFF005500740069006c0069007a006500200065007300740061007300200063006f006e00660069006700750072006100e700f5006500730020007000610072006100200063007200690061007200200064006f00630075006d0065006e0074006f0073002000500044004600200063006f006d00200075006d00610020007200650073006f006c007500e700e3006f00200064006500200069006d006100670065006d0020007300750070006500720069006f0072002000700061007200610020006f006200740065007200200075006d00610020007100750061006c0069006400610064006500200064006500200069006d0070007200650073007300e3006f0020006d0065006c0068006f0072002e0020004f007300200064006f00630075006d0065006e0074006f0073002000500044004600200070006f00640065006d0020007300650072002000610062006500720074006f007300200063006f006d0020006f0020004100630072006f006200610074002c002000520065006100640065007200200035002e00300020006500200070006f00730074006500720069006f0072002e00200045007300740061007300200063006f006e00660069006700750072006100e700f50065007300200072006500710075006500720065006d00200069006e0063006f00720070006f0072006100e700e3006f00200064006500200066006f006e00740065002e> /DAN <FEFF004200720075006700200064006900730073006500200069006e0064007300740069006c006c0069006e006700650072002000740069006c0020006100740020006f0070007200650074007400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006d006500640020006800f8006a006500720065002000620069006c006c00650064006f0070006c00f80073006e0069006e0067002000740069006c0020007000720065002d00700072006500730073002d007500640073006b007200690076006e0069006e0067002000690020006800f8006a0020006b00760061006c0069007400650074002e0020005000440046002d0064006f006b0075006d0065006e007400650072006e00650020006b0061006e002000e50062006e006500730020006d006500640020004100630072006f0062006100740020006f0067002000520065006100640065007200200035002e00300020006f00670020006e0079006500720065002e00200044006900730073006500200069006e0064007300740069006c006c0069006e0067006500720020006b007200e600760065007200200069006e0074006500670072006500720069006e006700200061006600200073006b007200690066007400740079007000650072002e> /NLD <FEFF004700650062007200750069006b002000640065007a006500200069006e007300740065006c006c0069006e00670065006e0020006f006d0020005000440046002d0064006f00630075006d0065006e00740065006e0020007400650020006d0061006b0065006e0020006d00650074002000650065006e00200068006f00670065002000610066006200650065006c00640069006e00670073007200650073006f006c007500740069006500200076006f006f0072002000610066006400720075006b006b0065006e0020006d0065007400200068006f006700650020006b00770061006c0069007400650069007400200069006e002000650065006e002000700072006500700072006500730073002d006f006d0067006500760069006e0067002e0020004400650020005000440046002d0064006f00630075006d0065006e00740065006e0020006b0075006e006e0065006e00200077006f007200640065006e002000670065006f00700065006e00640020006d006500740020004100630072006f00620061007400200065006e002000520065006100640065007200200035002e003000200065006e00200068006f006700650072002e002000420069006a002000640065007a006500200069006e007300740065006c006c0069006e00670020006d006f006500740065006e00200066006f006e007400730020007a0069006a006e00200069006e006700650073006c006f00740065006e002e> /ESP <FEFF0055007300650020006500730074006100730020006f007000630069006f006e006500730020007000610072006100200063007200650061007200200064006f00630075006d0065006e0074006f0073002000500044004600200063006f006e0020006d00610079006f00720020007200650073006f006c00750063006900f3006e00200064006500200069006d006100670065006e00200071007500650020007000650072006d006900740061006e0020006f006200740065006e0065007200200063006f007000690061007300200064006500200070007200650069006d0070007200650073006900f3006e0020006400650020006d00610079006f0072002000630061006c0069006400610064002e0020004c006f007300200064006f00630075006d0065006e0074006f00730020005000440046002000730065002000700075006500640065006e00200061006200720069007200200063006f006e0020004100630072006f00620061007400200079002000520065006100640065007200200035002e003000200079002000760065007200730069006f006e0065007300200070006f00730074006500720069006f007200650073002e0020004500730074006100200063006f006e0066006900670075007200610063006900f3006e0020007200650071007500690065007200650020006c006100200069006e0063007200750073007400610063006900f3006e0020006400650020006600750065006e007400650073002e> /SUO <FEFF004e00e4006900640065006e002000610073006500740075007300740065006e0020006100760075006c006c006100200076006f0069006400610061006e0020006c0075006f006400610020005000440046002d0061007300690061006b00690072006a006f006a0061002c0020006a006f006900640065006e002000740075006c006f0073007400750073006c00610061007400750020006f006e0020006b006f0072006b006500610020006a00610020006b007500760061006e0020007400610072006b006b007500750073002000730075007500720069002e0020005000440046002d0061007300690061006b00690072006a0061007400200076006f0069006400610061006e0020006100760061007400610020004100630072006f006200610074002d0020006a0061002000520065006100640065007200200035002e00300020002d006f0068006a0065006c006d0061006c006c0061002000740061006900200075007500640065006d006d0061006c006c0061002000760065007200730069006f006c006c0061002e0020004e00e4006d00e4002000610073006500740075006b0073006500740020006500640065006c006c00790074007400e4007600e4007400200066006f006e0074007400690065006e002000750070006f00740075007300740061002e> /ITA <FEFF00550073006100720065002000710075006500730074006500200069006d0070006f007300740061007a0069006f006e00690020007000650072002000630072006500610072006500200064006f00630075006d0065006e00740069002000500044004600200063006f006e00200075006e00610020007200690073006f006c0075007a0069006f006e00650020006d0061006700670069006f00720065002000700065007200200075006e00610020007100750061006c0069007400e00020006400690020007000720065007300740061006d007000610020006d00690067006c0069006f00720065002e0020004900200064006f00630075006d0065006e00740069002000500044004600200070006f00730073006f006e006f0020006500730073006500720065002000610070006500720074006900200063006f006e0020004100630072006f00620061007400200065002000520065006100640065007200200035002e003000200065002000760065007200730069006f006e006900200073007500630063006500730073006900760065002e002000510075006500730074006500200069006d0070006f007300740061007a0069006f006e006900200072006900630068006900650064006f006e006f0020006c002700750073006f00200064006900200066006f006e007400200069006e0063006f00720070006f0072006100740069002e> /NOR <FEFF004200720075006b00200064006900730073006500200069006e006e007300740069006c006c0069006e00670065006e0065002000740069006c002000e50020006f00700070007200650074007400650020005000440046002d0064006f006b0075006d0065006e0074006500720020006d006500640020006800f80079006500720065002000620069006c00640065006f00700070006c00f80073006e0069006e006700200066006f00720020006800f800790020007500740073006b00720069006600740073006b00760061006c00690074006500740020006600f800720020007400720079006b006b002e0020005000440046002d0064006f006b0075006d0065006e0074006500720020006b0061006e002000e50070006e006500730020006d006500640020004100630072006f0062006100740020006f0067002000520065006100640065007200200035002e00300020006f0067002000730065006e006500720065002e00200044006900730073006500200069006e006e007300740069006c006c0069006e00670065006e00650020006b0072006500760065007200200073006b00720069006600740069006e006e00620079006700670069006e0067002e> /SVE <FEFF0041006e007600e4006e00640020006400650020006800e4007200200069006e0073007400e4006c006c006e0069006e006700610072006e00610020006e00e40072002000640075002000760069006c006c00200073006b0061007000610020005000440046002d0064006f006b0075006d0065006e00740020006d006500640020006800f6006700720065002000620069006c0064007500700070006c00f60073006e0069006e00670020006600f60072002000700072006500700072006500730073007500740073006b0072006900660074006500720020006100760020006800f600670020006b00760061006c0069007400650074002e0020005000440046002d0064006f006b0075006d0065006e00740065006e0020006b0061006e002000f600700070006e006100730020006d006500640020004100630072006f0062006100740020006f00630068002000520065006100640065007200200035002e003000200065006c006c00650072002000730065006e006100720065002e00200044006500730073006100200069006e0073007400e4006c006c006e0069006e0067006100720020006b007200e400760065007200200069006e006b006c00750064006500720069006e00670020006100760020007400650063006b0065006e0073006e006900740074002e> >> >> setdistillerparams << /HWResolution [2400 2400] /PageSize [612.000 792.000] >> setpagedevice