Using the counter instruction
It is an instruction that can either count up or down when it's input is triggered and an output is activated when the set value is reached. It can be used to determine the number of times an event has happened in a process. In this section, we will be looking at the common counter instructions which include count up and count down.
Count up (CTU)
The count up instruction will count up or increase by 1 each time it's input is triggered (0 to 1) for example, when a button is pressed and released or when a sensor is activated. The counter's output will be energized when the number of times the input is triggered (current value of counter) equals or greater than the pre-set value (PV).
In this example, a pilot lamp (PL1) is connected to Q0.0. A PNP proximity sensor (NO) is connected to I0.0 and a normally open push button is connected to I0.1 as shown in the following wiring diagram:
