How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program
Hello friends! We hope you are very well! Today we are here for complementing our knowledge with one of the most important topics in PLC programming and practice its implementation in PLC ladder logic programming. Our topic today is about counters which help us to know the production size at any time, the repetition of specific tasks and events. Many real-life situation problems need counter like garage capacity should be tracked by using counters to report how many cars are inside and if there is room for incoming cars or it's full. Another critical problem is to count the repetitive tasks and events in manufacturing. Furthermore, counting products and pieces for taking an action like performing maintenance, stop operation, turn over to next production stage... et cetera.

Counter in conventional control

Counters are used in conventional or relay logic control. they mainly receive pulses and count these pulses and when it reaches a preset value the output coil of the counter is energized. They mostly include an LCD showing the counting as shown in figure 1.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 1: Omron counter [1]

The main idea of most counters is counting input pulses by using logic circuits i.e. flip-flop and determining the output based on which an output relay is energized. There are two main types of the counter as regards structure: synchronous counters when all flip-flops and asynchronous counters when each flip-flop is connected to its separate clock. In addition, counters can be classified based on functionality into UP, DOWN, and UP-DOWN counters. If you are not familiar with logic circuit components like flip-flops so do not worry as it's not our concern here. We just want to let you know how physical counters in the traditional controller are complicated and take a lot of space as we need hundreds of flip-flops and other circuit components to have a counter which counts for a limited number. Figure 2 shows the logic circuit of the counter that can count from 0 to 9. It utilizes 4 flip-flops as shown. The type of this counter is an asynchronous counter as each flip-flop takes its clock from the output of the previous flip-flop. Furthermore, table 1 lists the truth table of the counter. It shows how the counter determines the count based on the output Q0, Q1, Q3, and Q4. For example, when all outputs are zeroes, that means the counter reads zero. When Q0 is high, Q1 is low, Q2 is low, and Q3 is high, that means the counter reads 9. But in PLC, it's the easier story, it’s software counters with flexible functionality and usability as well as we will see in the next section. So let's enjoy learning and practicing counters in ladder logic programming.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 2: Asynchronous 0-9 counter

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Table 1: the truth table of 0-9 counter

Pulse to be counted Q3 Q2 Q1 Q0
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
 

Counter in PLC

Simply, Counter in plc is an instruction to count up or down to preset value and energize an output at reaching that preset value. There are three types of counters in PLC which are:

Count up type

In this counter, each time a trigger input signal has been received at (CU), the counter counts up until reaching the preset value (PV) to energize output as shown in figure 3. The counter has three inputs: the trigger command, the reload command, and the preset value to set to what number the maximum counter is going to count up. Furthermore, it has two outputs: the counter output which is turned to true when the counter reaches the PV values, and the current value (CV) which tells the current value at any time to whom the counter reaches.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 3: The counter Up instruction block [2]

Count down type

In this counter, each time a trigger input signal has been received at (CD), the counter counts down until it reaches zero at then the counter output is energized. As shown in figure 4, the counter has three inputs: the trigger command for counting down (CD), the reload command to reload to the PV value, and the preset value to set to what number the initial value from whom the counter starts the count down. Furthermore, it has two outputs: the counter output which is turned to true when the counter reaches the PV values, and the current value (CV) which tells the current value at any time to whom the counter reaches.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 4: The counter down instruction block[2]

Up-Down counters

In this counter, the two functions of the count up and count down can be combined in one block. each rising edge of a trigger input signal has been received at (CD), the counter counts down. And each time it receives a command trigger signal at (CU), it counts up and so on till it reaches the PV values. At then the counter output is energized. As shown in figure 5, the counter has five inputs: the trigger command for counting down (CD), the trigger command for count up (CU), the reload command to reload to the PV value, the reset command to reset to zero, and the preset value to set to what number the initial value from whom the counter starts counting up or down. Furthermore, it has three outputs: the counter down output (QD) which is turned to true when the counter reaches zero, the counter up output (QU) which goes to true when the counter reaches the PV value, and the current value (CV) which tells the current value at any time to whom the counter reaches.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 5: The counter Up-down instruction block[2]

Ladder program examples for counters

Now after we have introduced to counters in PLC as regard to their types, functionalities, inputs, and outputs, let’s get to have the fun of practicing our lab work for counters with our simulator.

Count up example

Figure 6 shows the ladder simple program example for a counter of type Up counter. In this example, the counter counts the input objects by a sensor that triggers the counter to increment. The ladder program is shown on the left side window while the simulator window appears on the right part. You can notice on the simulator window, we track all inputs and outputs as well. In the beginning, the current value (CV) is zero and the preset value is set to 10 meaning the counter will energize its output when it counts up to 10. Let’s press the input trigger and see what is going on. My friends, try to think before you go forward to see the simulator output as I am ganging will be the same as what you imagine!

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 6: Ladder example of a counter UP type

As you imagine exactly, figure 7 shows the counter is incrementing each time the input trigger signal is rising. Until it reach to or above 10 which is the PV value at then the counter output turns on as shown in figure 8.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 7: The counter incrementing with triggering signal input

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 8: the counter output turns ON by reaching to or above the PV value

On the other hand, the reset signal can be used for resetting the counter to the zero to start over counting as shown in Figure 9.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program
Figure 9: the counter CV reset to zero by hitting the reset.

Count down example

This counter is used to count down from the PV value to zero. Figure 10 shows a very simple ladder program for the count down the program on the left part and its simulation appears on the right as well. The simulation windows show the PV value is set to 10 and the current value (CV) is initially starting from the PV value. Therefore, it starts with a value of 10. So let’s try to hit the input CD signal and see what the simulator shows.

 

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program
Figure 10: Ladder example of count down counter

Figure 11 shows the counter is decrementing the CV by hitting the input CD. And continue decrementing until reaching zero. So what is going to happen then? Think!

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program
Figure 11: the counter is decrementing by hitting the input CD

Exactly! And well though, as figure 12 shows, once the counter reaches zero, the output changes to true.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program
Figure 11: the counter output set to TRUE when reaching zero

Again, the reset button can be utilized to reset the counter to its initial state as shown in figure 12. You can notice that the CV reset to 10 which is the initial value and equal to the preset value (PV).

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 12: Reset button reinitiate the counter to the PV value

Count up-down example

Now we are going to combine all features in the UP and down counters in one counter which is called the UP-Down counter. Figure 13 shows a simple ladder example for that counter. The ladder code is shown on the left and the simulator window is on the right. The simulation window shows all inputs and outputs of the UP-DOWN counter.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 13: A ladder example of UP-Down counter

Testing the up-down counter ladder program

We have two functions to test with this type of counter which is up counting and down counting. Figure 14 shows the initial state of the ladder program, it shows we start testing when the current value (CV) shows 2. So what do you expect when hitting the count up and the count down? Thinking and validate with the simulator results below.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 14: initial state at the running of the up-down example

By hitting the count-up function, the counter acts like a UP counter and the current value is incremented as in figure 15.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 15: count up function incremented the CV

On the other hand, by hitting the count down function, the counter acts as a down counter and the current value is decremented as in figure 16. And by pressing reset, the counter CV value will be reset to zero, while it reloaded to the PV value by pressing the load counter button. In addition, the output QU will be energized when the counter reaches or is higher than the PV value which is 10 in this example while the output QD will be true when the counter reaches zero. To sum up, this up-down counter can act as both types of counters UP and Down. I know someone is going to ask why we have such a counter when we already have one of each counter type? Well! That’s a really good question. And the answer is that, yes we can implement any problem relating to performing counting by using these two counters. However, some problems need to perform both functions UP and Down counting at the same time. For example, the Garage problem has cars getting in and out all the time and when cars get in we need to count up the cars and when cars get out we need to count down to report the number of cars in the garage at any time. So in such a problem, having one counter do the whole job is better than having two punters for reducing the conflictions and increasing the flexibility of calculations.

How to use counters in ladder logic programming, Counter in conventional control, Omron counter, Asynchronous 0-9 counter, Counter in PLC, Count-up type, Ladder program examples for counters, Count down example, Testing the up-down counter ladder program

Figure 16: count down function decremented the CV

Next topic

I would like to thank you so much for following up with us up to this point of learning and practice. Despite briefly introducing the logic gates, we will elaborate in the next station on the logic gates and their functions and usage in ladder logic programming. So you be ready for more learning and practice the ladder logic and logic gates in deep detail.