Most programmable logic controller (PLC) programs will include a counter instruction. The Productivity 2000 Series PLC has two different counter instructions for your program. These can be used in several different ways to adapt to your application. Basically, counters are used to count up or down to a specific limit. When the limit is reached, the output is turned on.
Counters can be made from a few different instructions from the PLC. The math instruction uses the one-shot (leading edge) input to add 1 to an internal register to keep track of the counter’s value. A comparison is used to compare this counter value to a set value (SV). The output is turned on if it is greater than or equal. Another input is used for the reset of the counter value. Copy is used to move the reset value into the counter value. This reset will usually override the counting application. Breaking down the counter’s essential operation will help us understand our application and how we can utilize counters in our automation programs.
The productivity suite software has Simple Counters (SCNT) and the Counters (CNT) instructions.
We will be reviewing these instructions and looking at how to implement them in our ladder logic program. Let’s get started.
Previously in this Productivity 2000 series PLC, we have discussed:
P2000 Hardware Features – Video
Productivity Suite Software Install – Video
Communication (System Configuration) – Video
First Program – Video
Debug Mode – Video
PLC Program Documentation – Video
PLC CPU Display – Video
PLC Online Programming – Video
PLC Tag Database – Video
Ladder Logic Contacts – Video
Ladder Logic Outputs – Video
Timers – Video
Simple Counters (SCNT)
Timing Diagrams – Productivity Counters
When dealing with all counters, we must look at the timing charts. This will help in understanding how your application will need to function. As a system integrator, this ability can prove very useful to you in the field when commissioning your automation system. The Secret of Using Counters is a good refresher on using timing charts.
Here is the YouTube video for this post:
We will first use the simple counters instruction. Using the Structure, the preset value, current value, and done bit are automatically assigned to the structure name. The addresses can be entered individually or through the Structure.
We have the One-Shot selected. This means that the counter will count as 1 for every transition from off to one of the inputs. The following post will explain the one-shot circuit in the PLC.
How to Make a One-Shot in the PLC – Video
Select Use Structure. The name will be Simple_Counter. When we do this, the following parameters are set:
Simple_Counter.Current – 32bit integer
Simple_ Counter.Done – Boolean
Simple_ Counter.Preset – 32bit integer
The following tags are then displayed. We will choose the preset value and current value to be retentive. If power is lost or the PLC mode changes from run to program mode, the values specified as retentive will remember. The initial preset value will be 5.
When switch one transitions from off to on (one-shot), the counter current value will increment by 1. Once the current value equals the preset value (5), the done bit will be set. The second rung of your ladder will turn on Out1 when the Done bit is on.
Reset of the counter (Current value set to zero.) is done by the second input of the simple counter. In our case, it is switch 2.
Note: The reset always overrides the count value input.
This will set up the following parameters:
Counter.Current – 32bit integer
Counter.Equal – Boolean
Counter.Greater – Boolean
Counter.Less – Boolean
Counter.Preset – 32bit integer
Counter.Reset – 32bit integer
Our first input (Switch3) will be the count-up. When this transitions from off to on the counter current value will increment by 1.
The second input (Switch4) will be the countdown. When this transitions from off to on the counter current value will decrement by 1. When both counter-up and counter-down inputs are triggered simultaneously, the counter-current value will not change.
The reset input will be done with Switch5. When activated, the reset value will be placed in the current value. This reset will override the up and down count inputs.
Watch the video below for the counter instructions used in our Productivity 2000 Series PLC.
Download the Productivity 2000 PLC ladder logic counters program here.
Productivity 2000 Series PLC from Automation Direct
Overview Link (Additional Information on the Unit)
Configuration (Configure and purchase a system – BOM)
User Manual and Inserts (Installation and Setup Guides)
Productivity Suite Overview (Features of the fully functional free software package for the Productivity Family of PLC (PAC) controllers)
Productivity Suite Programming Software (Free Download Link)
This software contains all the instructions and helps files for the Productivity Series.
Watch on YouTube: Productivity 2000 PLC Ladder Logic Counter
If you have any questions or need further information, please contact me.
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.
To get this free article, subscribe to my free email newsletter.
Use the information to inform other people how numbering systems work. Sign up now.
The ‘Robust Data Logging for Free’ eBook is also available for free download. The link is included when you subscribe to ACC Automation.