How to Use Counters in PLC Programming

How to Use Counters in PLC Programming

In some industrial applications, you may need to count the number of products, cycles, the number of times a field device has been turned on and off, etc. Then you may need to use those numbers for another function within the PLC. For instance, you may need to count the number of bottles that are going to be put in a box and then when the box is full, you want to command the conveyor belt’s motor to run. For these kinds of applications, there is an instruction in PLC programming which is called “counter”.

Subscribe Watch Trailer Share
How to Use Counters in PLC Programming
  • 90. Introduction to Counters in PLC Programming _ Part 1

    In some industrial applications, you may need to count the number of products, cycles, the number of times a field device has been turned on and off, etc. Then you may need to use those numbers for another function within the PLC. For instance, you may need to count the number of bottles that are...

  • 91. Introduction to Counters in PLC Programming _ Part 2

    Now let’s assume that I need to use the value counted by the counter somewhere else in the program.

  • 92. Factory Warehouse PLC Program

    In an industrial process, there may be a conveyor belt with an electric motor that moves the manufactured products from the factory floor to the warehouse.

    I’m going to write a simple PLC program for this system with the following conditions:

    1) The motor is going to turn on when the start...

  • 93. Custom Preset Values for Counters

    Let’s assume that there are already 100 products in the warehouse and I need the counter to start counting from this preset value.

  • 94. Temporary Product Storage Area PLC Program

    I have two conveyor belts, two sensors and a temporary product storage area. The products are passing in front of sensor number one on the conveyor belt and entering the storage area.
    The products will then be put on the second conveyor belt, pass in front of the sensor number two, and transferr...

  • 95. Bottle Filling Process PLC Program _ Part 1

    There is a bottle filling machine that fills the empty bottles on a conveyor belt with liquid from this tank. In this and the next lessons you’re going to learn how this machine works and how to write a professional PLC program that fully controls this machine.
    This filling machine has three op...

  • 96. Bottle Filling Process PLC Program _ Part 2

    Three position selector switches usually have one input and two outputs. The use of the terms input and output may be confusing but they should not be confused with inputs and outputs of PLC's. The term input refers to the power portion of the contacts that the switch contain while the outputs re...

  • 97. Bottle Filling Process PLC Program _ Part 3

    Previously, I wrote code for controlling the signal lamps and also running the motor in the clockwise direction. In this lesson, I’m going to write code for running the motor in the counter clockwise direction.

  • 98. Bottle Filling Process PLC Program _ Part 4

    In addition to sensor number 2, I have sensors at the two ends of the conveyer belt. As I previously said, I want sensor number 1 to count the number of empty bottles and sensor number 3 to count the number of filled bottles.

  • 99. Bottle Filling Process PLC Program _ Part 5

    After implementing the safety conditions, the PLC program is now complete and I can begin testing.

  • 100. Bottle Filling Process PLC Program _ Part 6

    With the current PLC program:

    1.Every time the motor turns off from the bottle blocking sensor number 2, the operator has to press the start switch again and this is clearly not what I wanted in the automatic mode.

    2.When a bottle gets in front of the sensor number 2 and the valve is open,...

  • 101. Bottle Filling Process PLC Program _ Part 7

    In this lesson, I'm going to replace this three position selector switch with a two position switch and then revise the software such that there won't be any change in the way that the machine operates. This means that with the new two position selector switch, I will be able to change the machin...

  • 102. How Many S7 Counters Can You Use in Your PLC Program?

    The number of S7 counters you can use in your program depends on the model of the CPU you're using in your project. How can you find out how many S7 counters you can use or what happens if you enter an out of range address in the software? These are what you'll learn after watching this lesson.

  • 103. How to Prevent Counter Value Reset When the PLC Power is Cut Off?

    When you're using counters in your PLC program, if the PLC goes into the stop mode or the power cuts off, you'll lose all of the counter values and these values cannot be restored after running the PLC again.
    There are some programming tools and setups in the "STEP 7" that can be used to protec...

  • 104. Extended Timing in PLC Programs Using a Combination of a Timer and Counter_ Part 1

    Previously, you learned that you can use S7 timers for the purpose timing in your programs. The maximum time value you can have for these timers is 2 hours and 46 minutes. But in some projects you may need longer time values. One way to increase the time value for timing is to use a combination o...

  • 105. Extended Timing in PLC Programs Using a Combination of a Timer and Counter _ Part 2

    The time value for the timer is currently 5 seconds and the counter value is 3. With these numbers, the fan should stay running for 5 seconds three times or 15 seconds. Now let's test the program one more time.

  • 106. Testing the PLC Program in Single Scan Mode

    Whether you’re testing a PLC program with an actual PLC or with a simulator, by default the CPU executes the program in continuous scan mode. However, the PLC simulator in STEP 7 is capable of executing the program in single scan mode as well.

    Now, you may be asking, “What is the difference b...

  • 107. Counter Bit Instructions in PLC Programming

    Some of the most often used instructions in PLC programming are comparator operations. In all of the previous PLC programs that we have worked with so far, we have mostly worked with bits. A bit has only two possible values of one or zero, true or false and based on these limited values you can e...