Articles BRX Do-More Counters Do-More EasyPLC Machine Simulator Inputs PLC PLC Basics PLC Learning

PLC Counter Programming – 3 Things to Know

PLC ladder logic counters are used in just about every PLC program. They will indicate how many times something has happened within the controller logic. Counters then can be used to trigger other outputs or items in the PLC. You can find counter applications in a variety of things every day.
PLC Counter Programming - 3 Things to Know
PLC Counter Programming - 3 Things to KnowWe will discuss three things you need to know when programming counters in the PLC. A sample program with a counter will be shown. This will have a 3D simulation with the PLC. Let’s get started.

1 – Basic Counter Inputs are One-Shot (Leading Edge)

The counter inputs are always a pulsed input or one-shot. These inputs pick up the leading edge of a transition from off to on. When a counter input turns on, we want to increment or decrement the counter value. Our input looks like the following:
PLC Counter Programming - 3 Things to KnowThe input is off and then transitions to on. It is on for some time and then transitions back to off.
A PLC scan is a cyclic event. The physical inputs are read, the program is executed, diagnostics & communication, and then the physical outputs are updated. This PLC scan happens very quickly. Modern PLC controllers have scan times of 1 millisecond or less. This means that the scan is happening more than 1000 times per second.
PLC Counter Programming - 3 Things to KnowIf we look at our input again with the scan time of the PLC, it will look something like this.
PLC Counter Programming - 3 Things to KnowThe input to our counter is scanned several times when it is off and on. Looking at the leading edge of the input is what all basic counters will do to ensure an accurate count.
PLC Counter Programming - 3 Things to KnowPLC programming software will often show you that the input is edge triggered. You will see the triangle on the input of the counter indicating this operation. This is the Do-More Designer PLC Programming Software. It is a fully functional free package with a simulator and communication, which we will show below.
Here are a couple of links to explain further the PLC program scan:
Understanding the PLC Program Scan
PLC Learning Series – Program Cyclic Scan

2 – Counters are Simple Math Instructions

All counters are just simple math instructions. We have an addition or subtraction with every counter input. This accumulated value is known as the present value (PV). The set value (SV) is compared to the present value, and an output is turned on.
Take a look at the following example:
Ladder Logic Sample ProgramInput X2 uses the leading edge in math instruction. This will increment the memory location D0. Then, D0 (PV) is compared to the number 3 (SV). If the comparison is true, the output Y1 is turned on. X3 acts as a reset and will move the value 0 into D0 (PV).
Breaking the counter into simple PLC instructions lets you see how the logic works. It will give you a better understanding of the counter operation.

3 – Timing Charts will Help

To fully understand how a counter works for a particular application, a timing chart will help. A timing chart will explain how the inputs, reset, SV, PV, and outputs will operate. Take a look at the following example.
PLC Counter Programming - 3 Things to KnowThis chart has a set value of 3. The leading edge of the input will increment the PV by one. The output is turned on when the PV is equal to the SV of 3. The output remains on until the reset input is on. This will put 0 into the PV of the counter and turn off the output. If the reset signal is on and an input turns on, this is ignored, and the counter will not increment.
Ladder Logic Sample ProgramHere is the PLC ladder logic with a counter that will do the same thing as the timing chart. Watch the video below to see this in operation in relation to the timing chart.

Bonus – PLC Counter Application – Apple Counter

We will now take a look at a PLC counter application in ladder logic. This example uses the EasyPLC Machine Simulator. It is part of the EasyPLC Software Suite.
PLC Counter Programming - 3 Things to Know

Apple Packaging – Operation
The start and stop pushbuttons are used to control the application. When the machine is started, the conveyor will start and move a box into position with photocell signal 1. The box will be loaded with 10 apples using the apple creator output. Photocell signal 2 will count the apples. When the set value is reached the apple creator is turned off, the box moves down the conveyor and another box arrives. The system then starts over again.
PLC Counter Programming - 3 Things to KnowThe EasyPLC machine simulator will communicate Modbus TCP (Ethernet) to the Do-More Designer PLC Simulator.
PLC Counter Programming - 3 Things to KnowThe Do-More PLC will communicate to the simulator with the Modbus area of memory. Outputs will be MI and inputs will be MC.
PLC Counter Programming - 3 Things to Know
Ladder Logic Sample ProgramThe apple packaging will start and stop with the control panel.
PLC Counter Programming - 3 Things to Know
Ladder Logic Sample ProgramThe apple box conveyor will be turned on when no box is observed in front of the photocell or when the box is full.
PLC Counter Programming - 3 Things to Know
Ladder Logic Sample ProgramThe apple creator output is on when a box is present and the count of apples is not complete.
Apple Counter
PLC Counter Programming - 3 Things to Know
Ladder Logic Sample ProgramThe counter will count 10 apples that pass through the photocell. Reset the counter on the trailing edge of the photocell 1. (Box on the conveyor.)
Ladder Logic Sample ProgramA timer is used to ensure there is time for the 10th apple to be counted and fall into the box.
Our program is complete. We can download this ladder logic to the Do-More simulator and run the Apple Packing EasyPLC simulator.
PLC Counter Programming - 3 Things to KnowWatch the video below to see this application in operation.

Download the PLC ladder logic program files here.

Watch below to see what you should know about PLC ladder logic counter-programming.

Free learning and training series for PLCs.
Click / Click PLUS (Koyo)
BRX Do-More
Productivity Series


C-More EA9 Series of HMI
(Webserver, FTP, Data Logging, Free Remote Apps, etc.)

Node-Red is a free IoT software hub that can communicate MQTT and many standard industrial protocols. This series will help you communicate to the PLC, create an HMI on any electronic device, log data to a database, and view the information on a spreadsheet for analysis.
Node-RED IoT enabling Software

EasyPLC Software Suite is a complete PLC, HMI, and Machine Simulator Software package. This PLC learning package includes the following:
Easy PLC – PLC Simulation allows programming in Ladder, Grafcet, Logic Blocks, or Script.
HMI System – Easily create a visual human-machine interface (HMI)
Machine Simulator – A virtual 3D world with real-time graphics and physical properties. PLC programs can be tested using the EasyPLC or through other interfaces. (Modbus RTU, TCP, etc.)
Machine Simulator Lite – Designed to run on Android Devices.
Machine Simulator VR – Virtual Reality comes to life so you can test, train or practice your PLC programming.

Purchase your copy of this learning package for less than USD 75 for a single computer install or less than USD 100 to allow different computers.
Receive 10% off the price by typing in ACC in the comment section when you order.
Learn PLC programming the easy way. Invest in yourself today.

Watch on YouTube: PLC Counter Programming – 3 Things to Know

If you have any questions or need further information, please contact me.
Thank you,

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.

Leave a Reply

Your email address will not be published.