Seven segment multiplexing using 8051 microcontroller (AT89C51)

Summary

Many electronic devices use four seven segment displays to display their output. The four seven segment displays can be connected in two ways. One way is to connect the four displays to the four ports of the microcontroller. However this is not a good way, as this will block all the ports and we cannot use microcontroller for any other purpose.

 

To overcome this problem, we use multiplexing of seven segment display. In multiplexing we use the concept of persistence of vision i.e., human brain cannot differentiate between two events occurring at a time difference of less than .04 sec. In this case the four digits are displayed one after the other so fast that the human brain cannot detect the difference. Although only one digit is displayed at a time it appears as a four digit number.

The circuit presented here demonstrates the above principle in form of a counter which counts from 0 to 9999 with a small delay.
Seven segment multiplexing using 8051 microcontroller (AT89C51)

Description

The four seven segments are connected as shown in the circuit diagram. The ‘a’ to ‘g’ pins of all the segments are interconnected to each other and connected to the data port P2 of the microcontroller. All the ‘a’ pins are connected to the pin P2.0, ‘b’ to P2.1 and so on. The four control pins from the controller AT89C51 are connected to the four pins of the port P1 as per the diagram.

The control pins are used to enable the seven segments. Whenever a high is given to any of the control pin, the corresponding seven segment gets activated. As a result the data corresponding to the first digit is sent on the port P2, which gets displayed. To display the next digit, the next seven segment is activated and the corresponding data is loaded on port P2. Similarly the third and four digits are displayed and the process keeps repeating.

 

The speed at which the four segments are activated one after the other is so fast that it appears as if a four digit number is displayed and not a single digit one after the other. Refer Interfacing seven segment displays for more details on the values to be loaded on port P2 to display digits 0 to 9. Here we have used Timer0 interrupt to constantly switch the seven segment one after the other.  (Refer Timer programming for more details) The digits are switched after a time interval of approximately 2.5 millisecond. This delay is produced by the Timer0 of the controller.
 
As soon as the supply is switched on, the microcontroller AT89C51 starts counting from 0 to 9999. The counter is incremented by one after a delay of one second. To produce this delay Timer1 has been used. After every 2.5 millisecond the Timer0 interrupt function is called and the value of the counter is displayed as per the explanation earlier.
 
 

 

Circuit Diagram

Video

Code

This Code is only visible to Registered users. Please Login/Register

 

Components

BC547 | Transistor BC547  | PDF Datasheet
Transistor BC547
BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of resistance, is commonly used to amplify current. A small current at its base controls a larger current...
7 Segment Display | Seven Segment LED Display
Seven Segment Display
 
A seven segment display is the most basic electronic display device that can display digits from 0-9. They find wide application in devices that display numeric information like digital clocks, radio, microwave ovens...
AT89C51 Microcontroller, Atmel 89C51 Controller Image
AT89C51 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (...

You are here