Multiplexing 7-Segment Displays 3 Digit 7-Segment Interfacing With PIC Microcontrollers

Previous Tutorial Previous Tutorial Tutorial 33 Next Tutorial Next Tutorial
Multiplexing 7-Segment Displays | Multi-Digit 7-Segments Interfacing
Introductory Level

 

Multi-Digit 7Segments Tutorial Thumbnail

 

 

In this tutorial, we’ll be discussing how to interface multiple digits 7-Segments display with pic microcontrollers, or any other MCUs, generally speaking. I’ll briefly introduce the phenomenon called “persistence of vision” and how we can use it in embedded systems to trick the human eye by multiplexing displays in order to reduce the pin-count required to drive these output 7-segment display units.

By the end of this tutorial, you should be able to implement your own multi-digit 7-segments display controller. And you’ll create a couple of simple projects to test things out. First of which is a 3-Digit counter and the other is a 3-Digit ADC result display. Without further ado, let’s get right into it!


   Required Components For This Tutorial   

 

Qty. Component Name Buy On Amazon.com
1 PIC18F2550 Add
1 BreadBoard Add
1 Multi-Digit 7-Segment Display Add
1 Potentiometers Add
Resistors Kit Add    Add
1 Capacitors Kit Add    Add
1 Jumper Wires Pack Add    Add
1 LM7805 Voltage Regulator (5v) Add
1 Crystal Oscillator Add
1 PICkit2 or 3 Programmer Add
2 9v Battery or DC Power Supply Add    Add    Add

My DSO Siglent-SDS1104 (on Amazon.com)

My Function Generator Fy-6900 (on Amazon.com)

*Affiliate Links Disclosure: links will make me a small commission at no additional cost to you*

The Prototyping Board Setup

Prototyping Board - Embedded Systems Tutorials With PIC MCUs

 


   7-Segments Display Interfacing   

 

In a previous tutorial (7-Segments display interfacing), I’ve demonstrated how to interface a single 7-Segment display unit to display a single-digit number. However, in many situations, it won’t be enough and you’ll need to add more digits and of course, you can’t reserve 7 io pins for each one of them!

Moreover, adding many 7-segments comes at a cost indeed. And at some point, you’ll find out that an LCD module would have given you more display digits at the same, or less cost. And it’ll be your decision to chose one over the other.

The LCD display will give you more digits with less price per digit. But, it’ll be smaller and harder to see. A user can see clearly the LCD display from a distance no more than 1 meter.

On the other hand, the 7-segments display units are larger in size and could be easily seen by users from a greater distance. That’s the trade-off you’ll have to decide on, depending on your project case.

 


   Persistence of Vision – POV   

 

Persistence of vision (POV) refers to the optical illusion that occurs when visual perception of an object does not cease for some time after the rays of light proceeding from it have ceased to enter the eye. The human eye receives the light rays and sends the signals to the brain where perception occurs. The image you see inside your brain takes some time to fade away after it actually disappears in front of your eyes.

Therefore, the eye could be easily tricked by changing a scene fast enough so that the brain perceives an object in two places at the same time. A very clear example of this is the fan blades. While a fan is spinning the blades will seemingly appear to be in multiples positions at the same time due to the POV.

 In the animation below, the magician is holding a circular card. On the front face, there is a bird & on the backside, there is an empty cage. But as he spins the card fast enough, your eye will be tricked and your brain will perceive a bird in cage image, which doesn’t actually exist.

 

The animation below is just a few pictures being displayed one by one but fast enough so that you can feel the overlapping in your mind. Due to the fact that an image takes some time to fade away in your brain.

 

There are many applications for this phenomenon in embedded systems, where we take advantage of this fact in order to optimize our systems by tricking the human eye. One of them is the multiplexed 7-Segments display which we’ll implement today. And a very common example you might have seen before is the POV Watch. A led bar rotating very fast with a motor mount, so we can make the LEDs “appear” to be in multiple places, therefore we can draw whatever we want using only a strip of LEDs instead of a huge LED matrix.

 


   Multiplexing 7-Segment Displays   

 

The key idea of controlling multiple 7-segment displays is to use the same 7 IO output pins for all the segment lines. And also an additional control pin (transistor) to activate each 7-segment unit one at a time. And keep switching between all the digits fast enough to seemingly look as if they are lit at the same time.

Down below is a schematic diagram for a 3-Digit 7-Segment display unit and how to hook it up to your microcontroller.

(in case of Using 3 Different 1-Digit 7-Segment Display Units)

3 Digit 7-Segments Multiplexing Driving With Microcontroller

(in case of Using a Single 3-Digit 7-Segment Display Unit)

7-Segments Multiplexing 3-Digit 7-Segments Display Interfacing With PIC

Quick and dirty drawing but hopefully indicates how it will be hooked up.

Note that: in the second diagram, I’ve forgotten to add current limiting resistors for the 7-Segments. You can place a single resistor at the emitter to the ground connection. Or alternatively, one resistor for each line of the 7-Segments. And be aware that placing a single resistor at the emitter will cause non-consistent brightness among different segments. So you should predict that some segments will be brighter than others.

PCBgogo Ad

 


   3 Digit 7-Segment Display Counter – LAB1   

 

Lab Name 3-Digit 7-Segment Display Counter
Lab Number 45
Lab Level Intermediate
Lab Objectives Learn how to interface multiple digits 7-segments display with microcontrollers. And implement a multiplexing technique in order to reduce the required pin-count for the control process.

 

       1. Coding       

 

Open the MPLAB IDE and create a new project name it “Multiple_7Segments”. If you have some issues doing so, you can always refer to the previous tutorial using the link below.

Create New Project With MPLAB IDE

Set the configuration bits to match the generic setting which we’ve stated earlier. And if you also find troubles creating this file, you can always refer to the previous tutorial using the link below.

Now, open the main.c file and let’s start developing the firmware for our project.

The full code listing for this lab is as follows

 

Project Files Download

 

       2. Prototyping       

 

Here is a short demo video for the running test for this LAB

 

Play Video On YouTube

 


   3 Digit 7-Segments + ADC With PIC – LAB2   

 

Lab Name 3-Digit 7-Segment Display With ADC
Lab Number 46
Lab Level Intermediate
Lab Objectives Learn how to interface multiple digits 7-segments display with microcontrollers. And implement a multiplexing technique in order to reduce the required pin-count for the control process.

 

       1. Coding       

 

Open the MPLAB IDE and create a new project name it “Multiple_7Segments_ADC”. If you have some issues doing so, you can always refer to the previous tutorial using the link below.

Create New Project With MPLAB IDE

Set the configuration bits to match the generic setting which we’ve stated earlier. And if you also find troubles creating this file, you can always refer to the previous tutorial using the link below.

Now, open the main.c file and let’s start developing the firmware for our project.

The full code listing for this lab is as follows

 

Project Files Download

 

       2. Prototyping       

 

Here is a short demo video for the running test for this LAB

 

Play Video On YouTube

 


 

 

 

 

Previous Tutorial Previous Tutorial Tutorial 33 Next Tutorial Next Tutorial
Share This Page With Your Network!

Khaled Magdy

I'm an embedded systems engineer doing both Software & Hardware. I'm an EE guy who studied Computer Engineering, But I'm also passionate about Computer Science. I love reading, writing, creating projects and Technical training. A reader by day a writer by night, it's my lifestyle. You can view my profile or follow me via contacts.

You may also like...

2 Responses

  1. osama says:

    Hello…
    Thanks about your great job
    i want to ask about how to multiplexing 7 segment which was connected with different port’s pins of micro controller.

    I saw an ESR meter for Kinsa which was written with JAL language ,i didn’t understand multiplexing method.

    can you kindly explain how to do it?
    thanks

  2. Luca says:

    Can you explain a bit it the code of the first program?
    Why have you used isr?

Leave a Reply

%d bloggers like this: