Lecture_10-Timers and Counters

advertisement
Timers and Counters
by
Dr. Amin Danial Asham
References
Programmable Controllers-Theory
and Implementation, 2nd Edition,
L.A. Bryan and E.A. Bryan
Timers
 PLC timers are internal instructions that provide the same
functions as hardware timers.
 They activate or deactivate a device after a time interval
has expired.
 Timers are used in applications to add a specific amount of
delay to an output in the program.
 Timer instructions are generally considered internal
outputs. Like relay-type instructions, timer instructions are
fundamental to the ladder diagram instruction set.
 Timer instructions may have one or more time bases (TB)
which they use to time an event. The time base is the
resolution, or accuracy, of the timer.
Timers (continue)
For instance, if a timer must time a 10 second event, the user must
choose the number of times the time base must be counted to get to
10 seconds.
• Therefore, if the timer has a time base of 1 second, then the timer must count
ten times before it activates its output.
• This number of counts is referred to as ticks.
• The most common time bases are 0.01 sec, 0.1 sec, and 1 sec. The following table
shows the number of ticks required for a 10 second count, based on different
time bases.
Timers (continue)
 Timers, must have two values, a preset value and an accumulated
value.
 These values are stored in register or word locations in the data table.
 The preset value is the target number of ticks that must be achieved
before the timer executes its timing function and sets the output
condition, which depends on the type of timer used.
 The accumulated value is the current number of ticks that have
elapsed during the timer.
 The preset value is stored in a preset register, while the accumulated
value is kept in an accumulated register.
 When the accumulated tick count equals the preset count, the timer
executes its timing function
Timers (continue)
 There are two formats used for timers.
a. A block format timer has one or two inputs, depending on the
PLC; control and Enable reset lines.
o If the control line is TRUE (i.e., it
has continuity) and the enable
line is also TRUE, the block
function will start timing.
b. A ladder format timer generally has only one input, which is the
control line. If the control line is ON, the timer will start timing.
Timers (continue)
ON-DELAY Timer
 An ON-delay (TON) output instruction either provides time delayed action or
measures the duration for which some event occurs.
 Once the rung has continuity(Timer control input is 1), the timer begins counting
time-based intervals (ticks) and counts down until the accumulated time equals
the preset time.
 When these two values are equal, the timer energizes the output and closes the
timeout contact associated with the output.
 If logic continuity (control input) is lost before the timer times out, the timer
resets the accumulated register to zero.
Delay
Timers (continue)
OFF-DELAY Timer
 An OFF-delay (TOF) output instruction provides time delayed action.
 If the control line rung does not have continuity (Timer control input is
zero) the timer begins counting time-based intervals until the
accumulated time value equals the programmed preset value.
 When these values are equal, the timer energizes the output and closes
the timed-out contact associated with the output.
 If logic continuity occurs before the timer times out, the accumulated
value resets to zero.
 Example: During a machine modernization project, it is found that part of a relay
ladder circuit (following figure), when translated into a PLC circuit, does not work
correctly. This malfunction is due to the fact that in the hardwired circuit, relay CR5,
which is driven by device LS4, had enough delay time to synchronize with the rest of
the circuit so that the solenoid actuation was correct. Now that it has been
implemented in the PLC, CR5 no longer has this delay. The delay needed is
estimated at 3 AC cycles (60 Hz) and the time bases available in the PLC are 0.01,
0.1, and 1 sec. Which time base should be used to create the delay and how many
ticks must the delay last?
 Solution
The estimated delay of 3 AC cycles translates into 60 Hz
𝟑
𝟑𝒄𝒚𝒄𝒍𝒆𝒔 =
= 𝟎. 𝟎𝟓 𝒔𝒆𝒄
𝟔𝟎
Thus, the required delay is 50 msec. Therefore, the only time base small enough to
use is 0.01 sec. Using this time base, the timer must count 5 ticks to create the delay.
Counters
 Counter instructions are used to count events, such as parts passing
on a conveyor, the number of times a solenoid is turned ON, etc.
 Counters, along with timers, must have two values, a preset value and
an accumulated value.
 These values are stored in register or word locations in the data table.
 The preset value is the target number of ticks or counting numbers
that must be achieved before the counter turns its output ON.
 The accumulated value is the current number of counts that have
elapsed during the counter operation.
 The preset value is stored in a preset register, while the accumulated
value is kept in an accumulated register.
Counters (continue)
 There are two basic types of counters: those that can count up and
those that can count down
 Depending on the controller, the format of these counters may vary.
oSome PLCs use the ladder format (output coil),
owhile others use functional block format.
Counters (continue)
Counters (continue)
 Up Counter
• An up counter (CTU) output instruction adds a count, every time its referenced
event occurs.
• In a control application, this counter turns a device ON or OFF after reaching a
certain count (i.e., the preset value in the preset register).
• Also, this counter can keep track of the number of parts (e.g., filled bottles,
machined parts, etc.) that pass a certain point.
• An up counter increases its accumulated value (the count value in its accumulated
register) each time the up-count event makes an OFF-to-ON transition.
• When the accumulated value reaches the preset value, the counter turns ON the
output, finishes the count, and closes the contact associated with the referenced
output.
• After the counter reaches the preset value, it either resets its accumulated register
to zero (a reset instruction is used to clear the accumulated value.) or continues
its count for each OFF-to-ON transition, depending on the controller.
Counters (continue)
 Down Counter
• A Down Counter (CTD) output instruction decreases the count value in its
accumulated register by one every time a certain event occurs.
• A down count occurs every time the down input of the counter transitions
from OFF to ON.
• In practical use, a down counter is used in conjunction with an up counter to
form an up/ down counter, given that both counters have the same reference
registers.
• Depending on the programmable controller, the down counter will either stop
counting down at zero or at a specified maximum negative value.
• In an up/down counter, the down counter provides a way to correct data that
is input by the up counter.
o For example, while an up counter counts the number of filled bottles that
pass a certain point, a down counter with the same reference address can
subtract one from the accumulated count value every time it senses an empty
or improperly filled bottle.
Counters (continue)
Counter Reset
• A counter reset (CTR) output instruction resets up
counter and down counter accumulated values to
zero.
• When programmed, a counter reset coil has the
same reference address as the corresponding
up/down counter coils. If the counter reset rung
condition is TRUE, the reset instruction will clear
the referenced address.
Counters (continue)
•Example
The counter will count up when
contact 10 closes
Count down when contact 11
closes
Reset register 1003 to 0 when
contact 12 closes.
If the count is equal to 15 as a
result of either an up or down
count output 100 will be ON.
If the contents of register 1003
are greater than 15, output 101
will be ON.
Output 102 will be ON if the
accumulated count value is less than 15.
 Example: In the following figure a block counter instruction being used to count parts
as detected by a photoelectric eye (PE) input. The preset value of counts is 500.
Modify this circuit so that it will automatically reset every time the counter reaches
500. Also, add the instructions necessary to implement an output coil that indicates
that the count has reached 500.
 Solution:
When the preset and accumulated
counts are equal, the counter output
100 turns ON, latching output 101 to
indicate a reached count.
This same counter output resets the
counter. Remember that the PLC has
already evaluated all inputs, so the
counter is reset in the following scan
The previous input 11 is used to manually
unlatch output 101
Example:
Re-implement the count
detection circuit using
interlocking standard outputs
and contacts instead of
latch/unlatch coils.
 Solution
An interlocking circuit that latches,
or traps the counter’s output,
indicating that the count value has
been reached.
Note that the reset push button
(input 11) is programmed normally
closed from a normally open input
device.
Thanks
Download