COUNTERS IN PLC - Portal PDF
COUNTERS IN PLC - Portal PDF
COUNTERS IN PLC - Portal PDF
Controller
(Counters)
Introduction
• Counters used in PLC’s serve the same function as
mechanical counters.
• Counters compare an accumulated value to a preset
value to control circuit functions.
• Control applications that commonly use counters
include the following:
- Count to a preset value and cause an event to occur
- Cause an event to occur until the count reaches a
preset value
COUNTER
• Electronic counters can count up, count
down, or be combined to count up and
down.
• They are dependent on external sources,
such as parts traveling past a sensor or
actuating a limit switch for counting.
COUNTER APPLICATIONS
Industrial Application
• A bottling machine, for example, may use a
counter to count bottles into groups of six for
packaging
Counter Speed
Reset # XXXX
PB1
CNT 001
PB2
#0010
CNT001 Y0
CNT001 Y1
END
Up-counter Program Timing Diagram
PB1
Y0
Y1
PB2
Counter Counting Sequence
The up-counter is incremented by 1 each time the
rung containing the counter is energized.
Generic up/down
counter program
Up/Down Counter Timing diagram
Preset Value = 3
Counter Example
• A counter might be used to keep track of the
number of vehicles in a parking lot.
• As vehicles enter the lot through an entrance
gate, the counter counts up.
• When the lot is full a sign at the entrance gate
turns on indicating the lot is full
Counter Example
Counter Example
• In this ladder diagram, we wait for the sensor
0000 to turn on.
• Each pulse transition change form logic 0 to
1, will count as 1
• When 10 pulse transition has achieved, the
CNT000 contact close and output 1002 turns
on.
• When input 0002 turns on, the counter
CNT000 will reset back to 0 causing its
contact to turn off (open), thereby making
output 1002 turn back off.
Counter Example
Example 1
00000
CNT 001
00002
#0010
CNT001 01002
END
Cascading Counters
Depending on the
application, it may be
necessary to count events
that exceed the maximum
number allowable per
counter instruction. One
way of accomplishing this is
by interconnection, or
cascading, two counters.
Cascading Counters
Example 2: Count to 20,000 counts
Example 3
Packaging line control
TIM 001
#6000
TIM 001
END
Combining Counter And Timer Functions
Bit shift instructions will shift bit status from a source bit
address, through a data file, and out to an unload bit, one
bit at a time.
There are two bit shift instructions: bit shift left (BSL),
which shifts bit status from a lower address number to a
higher address number through a data file; and bit shift
right (BSR), which shifts data from a higher address
number to a lower address number. Some PLCs provide a
circulating shift register function, which allows you to
repeat a pattern again and again.
Bit Shift Right And Bit Shift Left Registers
Input conditions
are not examined Jumped program
and outputs rungs (5,6,7) are
remain in their
not scanned by
last state
the processor
Jump-To-Label From Two Locations
20
20
20
FORCE
INSTRUCTION
Forcing External I/O Addresses
The forcing capability of a PLC allows the user to
turn an external input or output "on" or "off" from the
keyboard of the programmer.
L1 L2
Program
10
Forcing An Input Address On
Force> ON
Switch SW 13 is closed to
energize the TND
Normal program scan
instruction and stop all
scanning beyond this point.
MATH
INSTRUCTION
PLC math instructions allow you to perform arithmetic
functions on values stored in memory words.