Judy@4pcba.com
7:30 AM - 7:30 PM
Monday to Saturday

7 Segment Display:How Does it Work?

Introduction to 7-Segment Displays

A 7-segment display is an electronic device that can display decimal numerals and some alphabetic characters. It is widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information. The display consists of seven segments, each of which can be lit separately to create different patterns that represent numbers or letters.

How a 7-Segment Display is Structured

A typical 7-segment display consists of seven elongated LED or LCD segments arranged in a rectangular formation, as shown below. Each segment is labeled with a letter from A to G, and the decimal point (DP) is used for displaying numbers with decimal places.

 __A__
|     |
F     B
|__G__|
|     |
E     C
|__D__|  DP

When an electrical current passes through a segment, it illuminates, allowing it to be seen by the viewer. By illuminating different combinations of these seven segments, all numbers from 0 to 9 can be displayed, as well as some alphabetic characters.

Types of 7-Segment Displays

There are two main types of 7-segment displays:

  1. Common Cathode Display: In this type, all the cathodes of the LED segments are connected together and grounded, while the anodes are left free. To light up a segment, a positive voltage is applied to the corresponding anode.

  2. Common Anode Display: In this type, all the anodes of the LED segments are connected together and supplied with a positive voltage, while the cathodes are left free. To light up a segment, the corresponding cathode is grounded.

Comparison of Common Cathode and Common Anode Displays

Feature Common Cathode Common Anode
Segment Activation Positive voltage to anode Ground the cathode
Current limiting Resistor on anode Resistor on cathode
Interfacing with MCUs Active-high (logic 1) control Active-low (logic 0) control
Power Efficiency More efficient Less efficient

Driving a 7-Segment Display

To control a 7-segment display, you need a driver circuit that can switch the individual segments on and off. The most common method is to use a BCD (Binary Coded Decimal) to 7-segment decoder, such as the 7447 or 74LS47 IC.

BCD to 7-Segment Decoder

A BCD to 7-segment decoder is an integrated circuit that accepts a 4-bit BCD input and outputs the corresponding 7-segment display pattern. The decoder has four input pins (A, B, C, D) and seven output pins (a, b, c, d, e, f, g) that connect to the respective segments of the display.

The truth table for a common cathode 7-segment display using a BCD to 7-segment decoder is as follows:

Decimal BCD Input 7-Segment Output
0 0000 1111110
1 0001 0110000
2 0010 1101101
3 0011 1111001
4 0100 0110011
5 0101 1011011
6 0110 1011111
7 0111 1110000
8 1000 1111111
9 1001 1111011

Multiplexing 7-Segment Displays

When working with multiple 7-segment displays, such as in a digital clock or a multi-digit calculator, multiplexing is often used to reduce the number of I/O pins required. In a multiplexed display, the anodes (or cathodes) of the corresponding segments in each digit are connected together, and the common cathode (or anode) of each digit is connected to a separate control pin.

To display a number on a multiplexed display:

  1. Enable the first digit by applying the appropriate voltage to its common pin.
  2. Set the BCD input to the decoder for the desired number to be displayed on the first digit.
  3. Wait for a short period (a few milliseconds) to allow the digit to be visible.
  4. Disable the first digit and enable the second digit.
  5. Set the BCD input for the second digit.
  6. Repeat the process for all digits in the display.

By rapidly cycling through the digits and updating the BCD input, a multi-digit number can be displayed using fewer I/O pins than would be required for a non-multiplexed display.

Interfacing 7-Segment Displays with Microcontrollers

Microcontrollers, such as Arduino or Raspberry Pi, can be used to control 7-segment displays directly or through decoder ICs. Here’s an example of how to interface a common cathode 7-segment display with an Arduino using a 7447 BCD to 7-segment decoder:

  1. Connect the Arduino’s ground pin to the common cathode of the 7-segment display and the ground pin of the 7447 decoder.
  2. Connect the 7447’s A, B, C, and D pins to the Arduino’s digital pins (e.g., pins 2, 3, 4, and 5).
  3. Connect the 7447’s a, b, c, d, e, f, and g pins to the corresponding segments of the 7-segment display through current-limiting resistors (e.g., 220Ω).

Here’s a sample Arduino code to display numbers from 0 to 9 on the 7-segment display:

int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;

void setup() {
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);
  pinMode(pinD, OUTPUT);
}

void loop() {
  for (int i = 0; i < 10; i++) {
    displayNumber(i);
    delay(1000);
  }
}

void displayNumber(int number) {
  digitalWrite(pinA, number & 0x01);
  digitalWrite(pinB, (number >> 1) & 0x01);
  digitalWrite(pinC, (number >> 2) & 0x01);
  digitalWrite(pinD, (number >> 3) & 0x01);
}

Applications of 7-Segment Displays

7-segment displays find applications in various electronic devices and systems, such as:

  1. Digital clocks and watches
  2. Electronic meters (e.g., multimeters, pH meters)
  3. Basic calculators
  4. Scoreboard displays
  5. Elevator floor indicators
  6. Parking lot occupancy displays
  7. Vending machines and cash registers

Despite the advent of more advanced display technologies like LCDs and OLEDs, 7-segment displays remain popular due to their simplicity, low cost, and ease of use in applications that require basic numeric displays.

FAQ

  1. Q: Can a 7-segment display show all alphabetic characters?
    A: No, a standard 7-segment display can only display some alphabetic characters (A, C, E, F, H, I, J, L, O, P, S, U, and Y) due to the limited number of segments. To display all alphabetic characters, a more complex display like a 14-segment or 16-segment display is required.

  2. Q: How do I choose the appropriate current-limiting resistor for a 7-segment display?
    A: The value of the current-limiting resistor depends on the forward voltage and current of the LED segments, as well as the supply voltage. You can calculate the resistor value using Ohm’s law: R = (V_supply – V_forward) / I_forward. Typically, a 220Ω resistor is suitable for most 7-segment displays operating at 5V.

  3. Q: Can I control a 7-segment display directly from a microcontroller without using a decoder IC?
    A: Yes, you can control a 7-segment display directly from a microcontroller by connecting each segment to an individual I/O pin. However, this method requires more pins and may be less efficient than using a decoder IC, especially when working with multiple displays.

  4. Q: What is the difference between a static and a multiplexed 7-segment display?
    A: In a static 7-segment display, each digit has its own set of pins for the segments and the common cathode (or anode). In a multiplexed display, the corresponding segments of each digit are connected together, and the common cathode (or anode) of each digit is connected to a separate control pin. Multiplexed displays require fewer pins but need to be refreshed repeatedly to maintain the displayed content.

  5. Q: How can I display decimal points on a 7-segment display?
    A: Most 7-segment displays have a separate LED segment for the decimal point (DP). To display a decimal point, simply connect the DP pin to an I/O pin on your microcontroller or decoder IC and control it independently of the other segments.

Conclusion

7-segment displays are versatile and cost-effective components for displaying numeric and some alphabetic characters in electronic devices. By understanding how they work, the different types available, and how to interface them with microcontrollers, you can easily incorporate 7-segment displays into your projects. With the knowledge gained from this article, you should be well-equipped to start using 7-segment displays in your own electronic applications.