The CTU is an instruction that counts false-to-true rung transitions. Rung transitions can be caused by events occurring in the program. When rung conditions for a CTU instruction have made a false-to-true transition, the accumulated value is incremented by one count, provided that the rung containing the CTU instruction is evaluated between these transitions.
The accumulated value is retained when the rung conditions again become false. The accumulated count is retained until cleared by a reset (RES) instruction that has the same address as the counter reset. The control word for counter instructions includes six status bits, as indicated below
• CU Bit: This status bit is true when UP counter instruction is true.
• DN bit: This bit is true when accumulated value is equal to or greater than the present value of the counter.
• OV(Overflow) bit: when counter count value exceeds 32,767,this bit becomes true.
• UN(Underflow):It will go true when counter counts below -32,768.
• Accumulator Value (ACC): This is the number of false-to-true transitions that have occurred since the counter was last reset.
• Preset Value (PRE): Specifies the value which the counter must reach before the controller sets the done bit.
In the following example count up counter is used to control the Red and Green lamps. Operating pushbutton I:2/3 provides the off-to-on transition pulses that are counted by the counter. The preset value of the counter is set for 7. Each false-to-true transition of rung 1 increases the counter’s accumulated value by 1. After 7 pulses, or counts, when the preset counter value equals the accumulated counter value, output DN is energized. As a result, rung 2 becomes true and energizes output O:5/1 to switch the red pilot light on. At the same time, rung 3 becomes false and de-energizes output O:5/2 to switch the green pilot light off. The counter is reset by closing pushbutton I:2/1, which makes rung 4 true and resets the accumulated count to zero. Counting can resume when rung 4 goes false again.