Multiplexed Seven Segment Disply  
Seven Segment are the very commonly used disply devices. Many people use BCD to seven segment decoder approach to display 4 digit or more digits display using 7 Segments but it is not cost effective.

The most efficient way of multi digit seven sgment disply is to use Time division multiplexing of data to be displayed on a particular Display.

In this approach the basic concept is scan (enable-disable) all displays at a very high speed and put the appropriate data at the very right moment of time.







Now let me explain the basic concept behind Multiplexing of data.

Suppose we want to display 1 on display1, 2 on display2, 3 on display3 and 4 on display4. So according to concept of multiplexing we must put data corresponding to digit 1, when only display1 is enable.

Enable Display1 by applying a high pulse on base of BC548 at display1, now put the hex data corresponding to Digit 1 on the data lines that is Port0.

Similarly Enable display2 and put data of digit 2 and so on for display3 and display4.



Here again we need interrupts. You may ask why??

We need to perform two tasks simultanously - 1 is to enable disable displays at high speed and put the data at same time on the data lines. So we must perform one of these task in one of Interrupt service routine.



/*******************************************************************
Example program for a counter on seven segment display
This program simply display counts starting from 0 on display using concept of multiplexing
*******************************************************************/


#include<at89x52.h>


//P1.0 dis 1
//p1.1 dis 2
//p1.2 dis 3
//p1.3 dis 4
//P0.0 to 0.6 a,b,c,d,e,f,g


// These hex values in array are calculated on the basis of combinationd of LEDs required to display digits from 0 - 9

unsigned char a[11]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x67,0x40};


int i,j,k,l,m,c;


void timer0(void) interrupt 1 using 2
{
 c++;
if(c==10000)
{
 m++;
 if(m>9)
 {
  m=0;
  l++;
 }
 if(l>9)
 {
  l=0;
  k++;
 }
 if(k>9)
 {
  k=0;
  j++;
 }
 if(j>9)
 {
  j=0;
 }
 c=0;
}
}


void delay()
{
int j;

for(j=0;j<50;j++)
{}
}


void main()
{

TMOD=0x02;
TH0=0xA4;
IE=0x82;
TR0=1;
P1=0x00;
P0=0x00;
j=0;
k=0;
l=0;
m=0;
c=0;
while(1)
{
P1=0xF1; //Leftmost Display enable
P1=~a[j];
P1=~a[j];
P1=~a[j];
P1=~a[j];
delay();
P1=0xFF;
P3=0xF2; // third form right display enabled
P1=~a[k];
P1=~a[k];
P1=~a[k];
P1=~a[k];
delay();
P1=0xFF;
P3=0xF4; // Second from right display enabled
P1=~a[l];
P1=~a[l];
P1=~a[l];
P1=~a[l];
delay();
P1=0xFF;
P3=0xF8; // Rightmost display enable
P1=~a[m];
P1=~a[m];
P1=~a[m];
P1=~a[m];
delay();
P1=0xFF;
}

}






devesh@electroons.com
Best viewed at Firefox 1024x768 resolution