Multiplexing 7-segment displays is a technique used to reduce the number of control lines needed to drive multiple 7-segment displays in a digital system. Rather than driving each segment of every display independently, multiplexing allows for the display of multiple digits on a single set of lines by rapidly switching between them. This approach reduces the number of connections and simplifies the design, especially when dealing with multiple 7-segment displays in devices like clocks, counters, and digital meters.
A 7-segment display consists of 7 LED segments arranged in a figure-eight pattern. Each of these segments (labeled a, b, c, d, e, f, g) can be turned on or off to display a digit (0-9).
In a multiplexed system:
For a 2-digit display:
Common Cathode vs. Common Anode:
Scan Rate (Refresh Rate): The multiplexing involves switching between displays in a rapid sequence. For example, if there are two displays, the system will first display the number on the first display, then quickly switch to the second display. The time each display is on is short enough (milliseconds) to give the illusion that both displays are showing their respective digits at once.
Digit-to-7-Segment Mapping: Each of the digits (0-9) can be represented by a unique combination of segments turned on or off. For example:
Segment Control: Use the same set of control lines for all 7-segment displays. This means controlling which segments (a, b, c, d, e, f, g) should be lit for each digit.
Digit Selection: Each display (digit) needs to be turned on one at a time, so you need to have an additional control line (or set of control lines) to enable or disable each individual display. For example:
Timing: The displays are turned on in a sequence, with each display being activated for a brief period. For a 2-digit display, this could mean:
Refresh Cycle: This process is repeated fast enough (typically 50-100 times per second) so that the human eye perceives both digits as being displayed simultaneously.
Let’s assume we are working with a 2-digit, 7-segment display using a common cathode configuration. Here’s a simple process to multiplex it:
Each display is turned on for the same amount of time, but because of the rapid switching, both digits will appear to be displayed at the same time.
Here is a simple pseudocode or algorithm for multiplexing a 2-digit 7-segment display:
# Array to store digit-to-7-segment mapping
digit_to_segment = [
[1, 1, 1, 1, 1, 1, 0], # Digit 0 (a, b, c, d, e, f, g)
[0, 1, 1, 0, 0, 0, 0], # Digit 1
[1, 1, 0, 1, 1, 0, 1], # Digit 2
# Add the rest of the digits here...
]
# Function to display digits
def display_digit(digit, display_number):
segments = digit_to_segment[digit]
# Activate the appropriate display (0 for first display, 1 for second display)
if display_number == 0:
# Enable first display and set segments
enable_display_1()
set_segments(segments)
else:
# Enable second display and set segments
enable_display_2()
set_segments(segments)
# Turn off the other display
if display_number == 0:
disable_display_2()
else:
disable_display_1()
# Main multiplexing loop
while True:
for display_number in range(2):
for digit in [first_digit, second_digit]: # Replace with actual digits
display_digit(digit, display_number)
delay(5) # Wait for 5 ms (time each digit stays on)
In the above code:
digit_to_segment is an array where each index corresponds to the segments required to show a digit (0-9).display_digit is a function that turns on a specific digit on one of the displays.Multiplexing 7-segment displays is an efficient way to reduce the number of pins needed for controlling multiple displays. By rapidly switching between displays, the system creates the illusion that all the digits are being displayed at once. This technique is widely used in digital clocks, counters, and other devices requiring multiple digits, providing a cost-effective and simplified solution for controlling multiple displays.
Open this section to load past papers