You are on page 1of 45

Counters & shift registers

By
Dr.\Ehab EL-Rafai
Content
• Introduction to Counters
– Definition and basic concept
– Importance in digital electronics
• Types of Counters
– Binary Counters
– Up/Down Counters
– Synchronous Counters
– Asynchronous (Ripple) Counters
– Ring Counters
– Johnson (Twisted Ring) Counters
• Operating Principles
– Overview of each type's operation
– Timing diagrams and waveforms
continue
• Applications of Counters
– Frequency Division
– Digital Clocks and Timers
– Event Counting and Control
– Address Generation in Memory Devices
– Traffic Light Control Systems
– Industrial Control Systems
• Design Considerations
– Choosing the right type of counter for a given application
– Cascading counters for larger counting ranges
– Minimizing glitches and hazards
• Conclusion
– Recap of key points
– Importance of counters in digital systems
Introduction to Counters

• Definition
• A counter is a digital electronic device that is
used to count the number of times that a
particular event occurs. It operates by
incrementing (or decrementing) its count
based on a clock signal. Counters are widely
used in digital systems for various applications
such as frequency division, time
measurement, and control.
Basic Concept
• At its core, a counter consists of a set of flip-flops (memory cells)
that store the current count value. The flip-flops are connected in
such a way that they change state (count up or down) in response to
a clock signal. Each flip-flop represents a binary digit (bit) of the
counter's count value.
• When the counter reaches its maximum count value, it may either
stop counting (overflow) or reset to zero, depending on its design.
Counters can count up (increment) or down (decrement), and they
can be synchronous (all flip-flops change state simultaneously) or
asynchronous (flip-flops change state sequentially).
• Counters are essential components in digital systems, enabling them
to perform various tasks that require counting and timing
operations.
Importance in Digital Electronics
• Counters are fundamental building blocks in digital
electronics, playing a crucial role in various applications. They
are used to:
1. Frequency Division: Counters are used to divide the
frequency of a clock signal, generating lower-frequency clock
signals that are used in various parts of a digital system.
2. Time Measurement: Counters can be used to measure time
intervals by counting the number of clock cycles that occur
within a given period.
3. Event Counting and Control: Counters are used to count
events such as button presses, sensor activations, or signal
transitions, enabling the system to respond accordingly.
continue
4. Address Generation: In memory devices, counters are used to generate
sequential addresses for reading from or writing to memory locations.
5. Digital Clocks and Timers: Counters are used in digital clocks and
timers to keep track of time and generate clock signals for
synchronizing operations.
6. Traffic Light Control Systems: Counters are used to control the
sequencing of traffic lights at intersections, ensuring smooth traffic
flow.
7. Industrial Control Systems: Counters are used in industrial control
systems to track the number of products produced, monitor machine
operation, and control processes.
• In summary, counters are essential components in digital electronics,
enabling the implementation of various functions and control
mechanisms in digital systems.
Binary Counters
• Definition: Binary counters are the simplest type of counters, where the
count values are represented in binary form. They can be either
asynchronous (ripple) or synchronous.
• Asynchronous (Ripple) Binary Counters: In an asynchronous binary
counter, each flip-flop output serves as the clock input to the next flip-
flop in the chain. This causes a ripple effect, where each flip-flop changes
state one after the other. While simple, asynchronous counters are
slower than synchronous counters due to the ripple effect.
• Synchronous Binary Counters: In a synchronous binary counter, all flip-
flops change state simultaneously in response to a common clock pulse.
This allows for faster operation compared to asynchronous counters.
Synchronous counters are often used in applications where speed is
critical.
• Applications: Binary counters are used in a wide range of applications,
including frequency division, event counting, and digital clocks. They are
fundamental building blocks in digital systems.
continue
• Definition: Up/down counters are versatile counters that can increment (count
up) or decrement (count down) based on a control signal. This allows them to
be used in a variety of applications where counting in both directions is
required.
• Operation: Up/down counters typically have a direction control input that
determines the counting direction. When the direction control is high, the
counter increments (counts up) with each clock pulse. When the direction
control is low, the counter decrements (counts down).
• Applications: Up/down counters are used in applications where bidirectional
counting is needed, such as in measuring the position of a motor shaft,
implementing digital timers that count up and down, or in frequency
synthesizers for generating variable frequencies.
• Design Considerations: When designing with up/down counters, it's important
to consider the timing and synchronization requirements, especially when
switching between counting up and counting down modes.
Synchronous Counters
• Definition: Synchronous counters are a type of counter where all flip-flops
change state simultaneously in response to a clock pulse. This synchronous
operation allows for faster and more reliable counting compared to
asynchronous counters.
• Operation: In a synchronous counter, the clock input is connected to all flip-
flops, and each flip-flop is triggered by the same clock pulse. This ensures
that all flip-flops change state at the same time, eliminating the ripple effect
seen in asynchronous counters.
• Advantages: Synchronous counters are faster and more reliable than
asynchronous counters because all flip-flops change state simultaneously.
This makes them ideal for applications where speed and synchronization are
critical.
• Applications: Synchronous counters are used in various applications,
including digital clocks, frequency dividers, and sequence generators. They
are particularly useful in applications where precise timing and
synchronization are required.
Asynchronous (Ripple) Counters
• Definition: Asynchronous counters, also known as ripple counters, are a type of
counter where the clock signal of each flip-flop is derived from the output of the
previous flip-flop in the chain. This creates a ripple effect, where each flip-flop
changes state sequentially.
• Operation: In an asynchronous counter, the first flip-flop is triggered by the
external clock signal. Subsequent flip-flops are triggered by the output of the
previous flip-flop. This causes a delay between the triggering of each flip-flop,
leading to a ripple effect.
• Advantages: Asynchronous counters are simple to design and require fewer
components compared to synchronous counters. They are suitable for
applications where speed is not critical.
• Disadvantages: The main disadvantage of asynchronous counters is their slower
speed due to the ripple effect. Additionally, as the count value increases, the
propagation delay through the flip-flops also increases, leading to longer
counting times.
• Applications: Asynchronous counters are used in applications where speed is not
critical, such as in simple frequency dividers, event counters, and control circuits.
Ring Counters
• Definition: Ring counters are a type of counter where the output of one flip-flop is
connected to the input of the next flip-flop in a ring configuration. The last flip-
flop's output is fed back to the first flip-flop, creating a closed loop.
• Operation: In a ring counter, only one flip-flop is in the "1" state at any given time,
and the "1" state circulates around the ring with each clock pulse. This creates a
sequence of states, with each state represented by a unique combination of flip-
flop outputs.
• Advantages: Ring counters are simple to design and require fewer components
compared to other types of counters. They are useful for generating a sequence of
control signals or for implementing state machines.
• Applications: Ring counters are commonly used in applications where a sequence
of states is required, such as in shift registers, LED chasers, and in frequency
dividers.
• Example: A 4-bit ring counter consists of four flip-flops connected in a ring. The
output of each flip-flop is connected to the next flip-flop's input, and the last flip-
flop's output is fed back to the first flip-flop.
Johnson (Twisted Ring) Counters
• Definition: Johnson counters, also known as twisted ring counters, are a
variation of ring counters where the complement of each flip-flop's output is
connected to the next flip-flop's input in addition to the normal connection.
• Operation: In a Johnson counter, the "1" state circulates around the ring in
the same manner as a ring counter. However, the complemented outputs
create a different sequence of states compared to a traditional ring counter,
resulting in a sequence that goes through all possible states before repeating.
• Advantages: Johnson counters produce a non-repeating sequence of states,
which can be useful in applications such as frequency dividers, pseudo-
random number generators, and encoding schemes.
• Applications: Johnson counters are used in applications where a non-
repeating sequence of states is required, such as in frequency dividers,
pseudo-random number generators, and digital encoding schemes.
• Example: A 4-bit Johnson counter consists of four flip-flops connected in a
ring, with the complemented outputs of each flip-flop connected to the next
flip-flop's input.
Applications of Counters
• Frequency Division
• Application: Counters are commonly used for frequency
division, where they divide the frequency of an input clock
signal to generate a lower-frequency output signal.
• Operation: A counter is configured to count a certain number
of clock cycles before toggling its output. For example, a
divide-by-2 counter toggles its output every other clock cycle,
effectively dividing the input frequency by 2.
• Example: In a digital clock, a 1 Hz signal from an oscillator can
be divided by a counter to generate a 1-minute clock signal
(1/60 Hz) for the minutes display.
Digital Clocks and Timers
• Application: Counters are used in digital clocks and
timers to keep track of time by counting clock
cycles.
• Operation: Each digit of the clock (hours, minutes,
seconds) is represented by a set of counters that
increment every second, minute, or hour.
• Example: In a stopwatch, a counter is used to
count the number of seconds elapsed since the
start of the timer.
Event Counting and Control
• Application: Counters are used to count events
such as button presses, sensor activations, or signal
transitions.
• Operation: Each event triggers the counter to
increment, allowing the system to keep track of the
number of events that have occurred.
• Example: In a traffic light control system, counters
are used to control the sequencing of traffic lights
based on the number of cars waiting at each
intersection.
Address Generation in Memory Devices

• Application: Counters are used in memory


devices to generate sequential addresses for
reading from or writing to memory locations.
• Operation: The counter's output is used as the
address input to access different memory
locations sequentially.
• Example: In a microcontroller, a counter is used
to generate addresses to read instructions from
memory during program execution.
Industrial Control Systems
• Application: Counters are used in industrial control
systems to track the number of products produced,
monitor machine operation, and control processes.
• Operation: Counters are used to count the number
of products produced on a production line, monitor
machine uptime, and control the timing of industrial
processes.
• Example: In a manufacturing plant, counters are
used to track the number of products produced per
hour and control the timing of machine operations.
Design Considerations
• Choosing the Right Type of Counter
• Application Requirements: Consider the specific requirements of the
application, such as the counting range, speed, and complexity.
• Counting Direction: Determine if the counter needs to count up,
down, or both (bidirectional counting).
• Synchronous vs. Asynchronous: Decide between synchronous and
asynchronous counters based on the need for speed and
synchronization.
• Sequence Requirements: For applications requiring a specific
sequence of states, consider ring counters or Johnson counters.
• Cascading: If the counting range exceeds the capability of a single
counter, consider cascading multiple counters to achieve the desired
range.
Minimizing Glitches and Hazards
• Glitches: In asynchronous counters, glitches
can occur due to the ripple effect. Use
appropriate logic design techniques (such as
state machine design) to minimize glitches.
• Hazards: Hazards can occur in counters when
there are multiple inputs changing
simultaneously. Use hazard-free designs or
hazard mitigation techniques to ensure
reliable operation.
Timing and Synchronization

• Clock Frequency: Choose a clock frequency


appropriate for the application, ensuring that
the counter can operate within the required
timing constraints.
• Synchronization: Ensure that synchronous
counters are properly synchronized to the
clock signal to avoid timing issues.
4-bit synchronous up/down binary counter 74193
Design using 4 bit binary counter 74193
• 0 up to 15 /15 down to 0 and repeat
• 0 up to N1/N1 down to 0 and repeat
• N1 up to F / F down to N1 and repeat
• N1up to N2 / N2 down to N1 and repeat
Types of Shift Registers
• Serial-in Serial-out (SISO) Shift Register
• Operation: In a SISO shift register, data is
shifted in serially through one input and
shifted out serially through one output. It has
one input and one output for data.
• Applications: SISO shift registers are used in
serial data communication, such as in serial-
to-parallel and parallel-to-serial conversion.
Serial-in Parallel-out (SIPO) Shift Register

• Operation: In a SIPO shift register, data is


shifted in serially through one input and then
output in parallel through multiple outputs. It
has one input and multiple outputs for parallel
data.
• Applications: SIPO shift registers are used to
convert serial data into parallel data, such as
in parallel data transfer interfaces.
Parallel-in Serial-out (PISO) Shift Register

• Operation: In a PISO shift register, data is


input in parallel through multiple inputs and
then shifted out serially through one output. It
has multiple inputs and one output for serial
data.
• Applications: PISO shift registers are used in
applications where parallel data needs to be
converted into serial data, such as in serial
data transmission.
Parallel-in Parallel-out (PIPO) Shift Register

• Operation: In a PIPO shift register, data is


input and output in parallel through multiple
inputs and outputs. It has multiple inputs and
multiple outputs for parallel data.
• Applications: PIPO shift registers are used in
applications where parallel data needs to be
shifted or stored in parallel form, such as in
memory devices.
Universal Shift Register
• Operation: A universal shift register can
perform all shift operations (left shift, right shift,
parallel load) depending on the control inputs.
It is versatile and can be configured for different
shift operations.
• Applications: Universal shift registers are used
in applications where flexible data manipulation
is required, such as in arithmetic and logic units
(ALUs) and data processing systems.

You might also like