►Seven-Segment Display Example

The segments in a 7-segment display are arranged to form a single digit from 0 to F. We can display a multi-digit number by connecting additional displays. Even though LCD displays are more comfortable to work with, 7-segment displays are still standard in the industry. This is due to their temperature robustness, visibility and wide viewing angle. Segments are marked with non-capital letters: a, b, c, d, e, f, g and dp, where dp is the decimal point. The 8 LEDs inside each display can be arranged with a common cathode or common anode. With a common cathode display, the common cathode must be connected to the 0V rail and the LEDs are turned on with a logic one. Common anode displays must have the common anode connected to the +5V rail. The segments are turned on with a logic zero. The size of a display is measured in millimeters, the height of the digit itself (not the housing, but the digit!). Displays are available with a digit height of 7,10, 13.5, 20, or 25 millimeters. They come in different colors, including: red, orange, and green.

The simplest way to drive a display is via a display driver. These are available for up to 4 displays. Alternatively displays can be driven by a microcontroller and if more than one display is required, the method of driving them is called "multiplexing."

The main difference between the two methods is the number of "drive lines." A special driver may need only a single "clock" line and the driver chip will access all the segments and increment the display. If a single display is to be driven from a microcontroller, 7 lines will be needed plus one for the decimal point. For each additional display, only one extra line is needed. To produce a 4, 5 or 6 digit display, all the 7-segment displays are connected in parallel. The common line (the common-cathode line) is taken out separately and this line is taken low for a short period of time to turn on the display. Each display is turned on at a rate above 100 times per second, and it will appear that all the displays are turned on at the same time. As each display is turned on, the appropriate information must be delivered to it so that it will give the correct reading. Up to 6 displays can be accessed like this without the brightness of each display being affected. Each display is turned on very hard for one-sixth the time and the POV (persistence of vision) of our eye thinks the display is turned on the whole time. Therefore, the program has to ensure the proper timing, else the unpleasant blinking of display will occur.

Connecting a microcontroller to 7- segment displays in multiplex mode

Program "7seg.asm" displays decimal value of a number stored in variable D.
movlw .21 	 
movlw D 	; number 21 will be printed on 7seg display

Displaying digits is carried out in multiplex mode which means that the microcontroller alternately prints ones digit and tens digit. TMR0 interrupt serves for generating a time period, so that the program enters the interrupt routine every 5ms and performs multiplexing. In the interrupt routine, first step is deciding which segment should be turned on. In case that the tens digit was previously on, it should be turned off, set the mask for printing the ones digit on 7seg display which lasts 5ms, i.e. until the next interrupt.

For extracting the ones digit and the tens digit, macro digbyte is used. It stores the hundreds digit, the tens digit, and the ones digit into variables Dig1, Dig2, and Dig3. In our case, upon macro execution, Dig1 will equal 0, Dig2 will equal 2, and Dig3 will equal 1.

The following example shows the use of the macro in a program. Program prints a specified 2-digit number on a 7seg display in multiplex mode.

◄ Previous Page  |  Next Page ►

Back To Index


Sat Feb 24 2018, 03:35 AM
I want help for digital ic tester
Tue Feb 20 2018, 04:01 PM
Join up.. and post your problem
Mon Feb 19 2018, 11:17 AM
i needs help for my project
Mon Feb 19 2018, 11:16 AM
can i join you guys
Sun Feb 04 2018, 09:38 PM
Hi Dave. Good to see you.
Tue Jan 09 2018, 07:55 PM
It's been a few years since I poked around here - Hi all...
Mon Jan 08 2018, 07:19 PM
Hi TPS. it's been a while..
۞ TPS ۞
Sun Jan 07 2018, 06:42 PM
Thu Jan 04 2018, 01:50 PM
sayyad affrid
its AT89S52
Thu Jan 04 2018, 01:50 PM
sayyad affrid
sir, i want embedded c code for ultrasonic sensor having buzzer interfaced with AT9S52



Sat Feb 24 2018, 12:47 PM
Wed Feb 21 2018, 05:01 PM
Wed Feb 21 2018, 06:55 AM
Wed Feb 21 2018, 04:10 AM
Tue Feb 20 2018, 07:53 AM
Mon Feb 19 2018, 02:49 AM
Sun Feb 18 2018, 05:59 PM
Sat Feb 17 2018, 07:14 AM


Guests: 37, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37971
Newest member: Manojsanghavi
Forum Activity
Manojsanghavi Avatar
Posted By Manojsanghavi
Sat Feb 24 2018, 01:03 PM
Dear allCan someone please help me on how to progr...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 07:10 PM
sbit E = P0^7; //E pin for LCD //use port 0sb...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 02:43 PM
sbit NOT #definesbit E = P0^7; //E pin for LCD ...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 01:55 PM
change your defines tosbit E = P0^7; //E pi...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 01:12 AM
Add pull- ups for EN and RS.change your defines t...
Ansh12 Avatar
Posted By Ansh12
Thu Feb 22 2018, 01:36 AM
Can you post your Proteus files.ExperimenterUKThan...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 09:07 PM
The code you refer to is to drive the circuitshown...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 05:41 PM
Can you post your Proteus files.You will need pull...
radhikanathani Avatar
Posted By radhikanathani
Wed Feb 21 2018, 02:39 PM
I want to design a system for vehicle tracking and...
Narayani Avatar
Posted By Narayani
Wed Feb 21 2018, 04:17 AM
Hello,Your tutorial really helped me understand st...