A majority of programmable logic controller (PLC) programs will include a counter instruction. The Productivity 1000 Series PLC has a couple of different counter instructions for your program. Under the data handling instructions we have the increment / decrement instruction (INC). We could use this with the compare contact (CMP) instruction that we discussed in our Contact and Coil Instructions (Video) to create a counter application.
The productivity suite software has a Simple Counter (SCNT) and the Counter (CNT) instructions. We will be reviewing these instructions and looking how to implement then in our ladder logic program. Let’s get started.
Previously in this Productivity 1000 series PLC we have discussed:
System Hardware – Video
Installing the Software – Video
Establishing Communication – Video
First Program – Video
Documenting the Program – Video
Monitoring and Testing the Program – Video
Online Editing and Debug Mode – Video
Numbering Systems and Tag Database – Video
Contact and Coil Instructions – Video
Timer Instructions – Video
When dealing with counters, we need to look at timing charts. The Secret of Using Counters is a good refresher on using timing charts. As a system integrator, this ability can prove very useful to you in the field when commissioning your automation system.
Here is the URL of the video for the same post: https://youtu.be/pyNNKRA_xK8
Simple Counter (SCNT)
We will first use the simple counter instruction. The addresses can be entered individually or through the Structure. Using the structure, the preset value, current value and done bit are automatically assigned to the structure name.
We have the One Shot selected. This means that the counter will count 1 for every transition from off to on of the input. 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. This means that if power is lost or the PLC mode changes from run to program mode the values specified as retentive will remember their values. The initial preset value will be 10.
When switch 1 transitions from off to on (one shot) the counter current value will increment by 1. Once the current value is equal to the preset value (10) 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.
We will use the structure name of Counter. The One Shot will be selected for the inputs to the counter. (Transition from off to on.)
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
The following tags will now be defined. We will make the preset and current ones memory retentive. The preset value will be set for 10. This represents 10 counts for our counter.
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 count down. 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 at the same time the counter current value will not change.
The reset input will be done with Switch5. When this is 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 to see the counter instructions used in our Productivity 1000 Series PLC.
Download the PLC program here.
Productivity 1000 Series PLC form 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 Programming Software (Free Download Link)
This software contains all of the instruction sets and help files for the Productivity Series.
Next time we will look at math instructions in the Productivity 1000 Series PLC.
Watch on YouTube : Productivity 1000 Series PLC Counter Instructions
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 PLC’s are not difficult 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 as a free download. The link is included when you subscribe to ACC Automation.