Timers and Counters by Dr. Amin Danial Asham. References Programmable Controllers-Theory and...

19
Timers and Counters by Dr. Amin Danial Asham

Transcript of Timers and Counters by Dr. Amin Danial Asham. References Programmable Controllers-Theory and...

Page 1: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Timers and Counters

by

Dr. Amin Danial Asham

Page 2: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

References

Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan

Page 3: 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.

Page 4: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 5: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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

Page 6: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

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.

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.

Page 7: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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

Page 8: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 9: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 10: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 11: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 12: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Counters (continue)

Page 13: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 14: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 15: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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.

Page 16: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Counters (continue)•ExampleThe counter will count up when contact 10 closesCount down when contact 11 closesReset 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.

Page 17: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

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 scanThe previous input 11 is used to manuallyunlatch output 101

Page 18: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Example:

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.

Re-implement the count detection circuit using interlocking standard outputs and contacts instead of latch/unlatch coils.

Page 19: Timers and Counters by Dr. Amin Danial Asham. References  Programmable Controllers-Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Thanks