Appendix A_Supplemental Material_on_Timers & Counters

advertisement
Appendix A
Supplemental Material
On Timers & Counters
A
This product was funded by a grant awarded under the President’s Community-Based Job Training Grants as implemented by the
U.S. Department of Labor’s Employment & Training Administration. The information contained in this product was created by a
grantee organization and does not necessarily reflect the official position of the U.S. Department of Labor. All references to nongovernmental companies or organizations, their services, products, or resources are offered for informational purposes and should
not be construed as an endorsement by the Department of Labor. This product is copyrighted by the institution that created it and is
intended for individual organizational, noncommercial use only.
Supplemental Material: Timers
More complex systems cannot be controlled with combination logic alone.
The main reason for this is that we cannot, or choose not to add sensors to detect all
conditions. In these cases we can use events to estimate the condition of the system.
The common theme for all of these events is that they are based upon one of two
questions:
"How many?" or "How long?”
Logical Device vs. Event Based Device
The input to the device is a push button. When the push button is pushed the input
to the device turns on. If the push button is then released and the device turns off, it
is a LOGICAL device.
If when the push button is release the device stays on, we have one type of event
based device. The device is EVENT BASED if it can respond to one or more things
that have happened before.
e.g. A Start Push Button
Push Button
+V
Device
On/Off
Push Button
Device
(Logical Response)
Device
(Event Response)
time
Many events in an automated process are linked to time; either by when they
happen, or by how long they proceed. In order to automate any industrial process
when events happen in sequence, TIMERS are required.
Therefore, timers are one of the fundamental building blocks in PLC programming
for automation.
There are four fundamental types of timers as shown in the figure below:
PLC TIMERS
PLC timers are software versions of mechanical timers.
Much like the advanced mechanical timers, PLCs have many timing program
options which include: TON (timer on delay), TOF (timer off-delay), RTO
(Retentive time), and Cascade counting.
Using these four options, you will be able to control the timing in almost any
industrial process.
The advantages of PLC timers over other timers are that they can be easily inserted,
removed, easily altered, with no wires to change. They are also extremely accurate
and repeatable.
TIMER IDENTIFICATION
When programming PLC timers, there are several variables or quantities associated
with timer instructions.
First, all PLC timers require an address. The letter designation normally used for
timers is “T”. The T will be followed by a number designation for the location in
the PLC memory.
TIMEBASE
The time base is the basic interval of time used by the timer.
Some PLCs allow you to use different time bases such as seconds, tenths of a
second, hundredths of a second, and so on. In the Allen Bradley 5000, the time
interval is defaulted to 1/1000 of 1 second or 0.001 sec. This value cannot be
changed.
Example:
If you want a timer set for 0.5 seconds, you would set your timer at 500.
A setting of 2000 would give you a timing delay of 2 seconds.
PRESET TIME
The preset time is the time duration for the timing circuit.
ACCUMULATED TIME
The accumulated time is the elapsed time since the timer began timing.
PROGRAMMING BITS
Most PLC timers also have bits that are linked to your timer that can be used almost
anywhere in your ladder program to represent the timer’s status. The following
three are very commonly used.
EN represents the enable bit, which is usually active when the timer
instruction or the rung the timer is on is active.
TT is the timer timing bit and is activated only when the timer is actually
counting.
DN represents the “done” bit and is probably the most common timer bit.
DN goes active when the timer has completed its instructions. DN is
active usually only when the EN is also active.
TIMER ON-DELAY (TON)
Timer ON-delay, or TON, is used to turn an output bit on or off after a timer has
been enabled for the preset time interval.
In a TON timer, the accumulated time automatically returns to zero when the timer
is deactivated or the rung goes false.
TIMER ON-DELAY (TON) -- Operation
In step 1 of a timer’s operation, the timer is
disabled prior to any activity. All the instructtion bits are disabled.
In step 2, the timer is activated and the accumulator value will start incrementing.
To indicate this status the EN and TT instruction bits are set. You can use the TT
(Timer Timing) instruction bit in a PLC timing program to identify when a timer is
actively timing.
In step 3, the timer stops timing because the accumulator time value has reached the
preset time value. The TT bit turns off, and the DN (Done) bit turns on because the
timer is done timing. Use the DN bit to notify your process that it can now continue.
TIMER OFF-DELAY (TOF)
Timer OFF-delay, or TOF, is used to keep an output energized for a time period
after the rung containing the timer has gone false. The TOF timer has the same type
of instruction bits as a TON timer.
TIMER OFF-DELAY (TOF) -- Operation
In step 1, the timer is disabled prior to
any activity. All the instruction bits are disabled.
In step 2, the timer is activated by a true input condition, but does not start timing.
The EN and the DN instruction bits are set because the timer is enabled and the
preset and accumulated values are equal.
In step 3, the input condition goes false. The timer enable bit then turns off and the
timer starts timing. Once the accumulated value reaches the preset value, the timer
turns off and the DN bit turns off.
RETENTIVE TIMER (RTO)
Another useful timing instruction is
the retentive timer or RTO.
The RTO functions the same as the
TON with the exception that the timing
count does not reset if the rung should go false.
The retentive timer must use a RES bit instruction to reset the timer back to zero.
The RES command must be executed only once or the RTO timer will continuously
reset to zero and be unavailable for future use.
A retentive timer will sum all of the on or off times for a timer.
A RTO is typically used for tracking the time before maintenance is needed on a
part.
CASCADE TIMER
Cascade timing is a method of combining two or more timers in series so that extra
long timing sequences can be executed.
Typically a cascade timer is made of TON timers. The Allen-Bradley
ControlLogix’s preset value is derived from a 32-bit register. With all 32 bits set to
one we would have a preset value of 2,147,483,647. This is approximately 2 million
seconds which is roughly 23 days.
A method for making a timer for longer than the preset value is to use multiple
timers in series so that when each timer completes its preset time, it turns on a
subsequent timer until the total elapsed time has expired.
Supplemental Material: Counters
While some events in an automatic processor link to time, other events are linked to
quantity.
In a way similar to how timers work with time in a process, counters work with
quantities in a process.
Counters help you establish control over an automated process. Therefore, counters
are also an important part of PLC programming software.
Counters do exactly what the name implies, counters count. Counting is always
incremental by the same units and not exponential. Counting can be either up or
down.
COUNTERS
Counters are similar to timers except that they do not operate on an internal clock
but are dependent on an external signal for counting.
Most PLCs offer both up-counters and down-counters, as well as several variations.
Almost all counting functions can be accomplished by just up counters.
COUNTER TYPES
There are two basic counter types: count-up and count-down.
When the input to a count-up counter
experiences a false to true transition the
accumulated value will increment by 1.
If the accumulated value reaches the preset value the counter DN bit will set.
A count-down counter will decrement
the accumulated value until the preset
value is reached.
COUNTER BIT INSTRUCTIONS
The PLC counter looks and functions much like the PLC timer. There is an address
register called counter, a reset register, and an accumulated value register. There is
also an input line to the counter, a count up bit (similar to timer EN), and a DN bit.
ADDRESS
Every counter is assigned an address. A counter is usually identified by designating
the letter “C” to the address.
PLCs generally have many programmable counters. Modular PLCs can have as
many counters as internal memory will allow.
PRESET
In programming a PLC counter, you must always set the preset register. This is
where the counter set point is stored which is the final value when counting is done.
Most PLC counters will allow you to enter the value within the ladder program.
ACCUM
Accum is short for accumulated, which means the accumulated or current count
value.
This Accum value can be referenced almost anywhere in your ladder program by
using a compare instruction such as greater than (>) or equal to.
CU & DN BITS
The CU (count up) bit is on when the count input is enabled. It verifies that the
counter is enabled. The DN bit is on when the Accum value is equal to or greater
than the preset value.
RESET
Most PLC counters are retentive, that means that even if the PLC is shut down, and
then turned back on, the Accum value does not change. Therefore a common
method of resetting the Accum value back to zero is to use the RES instruction.
CASCADE COUNTERS
Occasionally, you may have applications where it is necessary to count objects or
events that exceed the maximum number of your PLC counter. For these
applications you can use a programming method called “Cascade Counters”.
One method of creating longer counts using integer registers is to connect two
counters in series. When one registers completes its count, and its DN bit is set, that
bit enables the second counter to start counting.
Download