welcome to my blog

Friday, 13 January 2012

INTERFACE OF LED DOT MATRIX TO P89C51RD2

       LED dot matrices are very popular means of displaying information as it allows both static and animated text and images. Perhaps, you have encountered them at gas stations displaying the gas prices, or in the public places and alongside highways, displaying advertisements on large dot matrix panels.
       In this experiment, we will discuss about the basic structure of a monochrome (single color) LED dot matrix and its interface with a microcontroller to display static characters and symbols. We will cover the animation stuff in next tutorial. I am using the P89C51RD2(NXP) micro-controller for demonstration, but this technique is applicable to any other microcontrollers that have sufficient I/O pins to drive the LED matrix.

Theory of LED dot matrix display

      In a dot matrix display, multiple LEDs are wired together in rows and columns. This is done to minimize the number of pins required to drive them. For example, a 8×8 matrix of LED's (shown below) would need 64 I/O pins, one for each LED pixel. By wiring all the anodes together in rows (R1 through R8), and cathodes in columns (C1through C8), the required number of I/O pins is reduced to 16. Each LED is addressed by its row and column number. In the figure below, if R4 is pulled high and C3 is pulled low, the LED in fourth row and third column will be turned on. Characters can be displayed by fast scanning of either rows or columns. This tutorial will  discuss the method of column scanning.
   

     The LED matrix used in this experiment is of size 5×7. We will learn how to display still characters in a standard 5×7 pixel format. The figure below shows which LEDs are to be turned on to display the English alphabet ‘A’. The 7 rows and 5 columns are controlled through the microcontroller pins. Now, lets see in detail how it works.
     Suppose, we want to display the alphabet A. We will first select the column C1 (which means C1 is pulled low in this case), and deselect other columns by blocking their ground paths (one way of doing that is by pulling C2 through C5 pins to logic high). Now, the first column is active, and you need to turn on the LED's in the rows R2 through R7 of this column, which can be done by applying forward bias voltages to these rows. Next, select the column C2 (and deselect all other columns), and apply forward bias to R1 and R5, and so on. Therefore, by scanning across the column quickly (> 100 times per second), and turning on the respective LED's in each row of that column, the persistence of vision comes in to play, and we perceive the display image as still.

 
     The table below gives the logic levels to be applied to R1 through R7 for each of the columns in order to display the alphabet ‘A’.



     You should have noted that across each row, one pin is sourcing the current for only one LED at a time, but a column pin may have to sink the currents from more than one LED. For example, the column C1 should be able to sink the currents from 6 LED's while displaying the alphabet ‘A’. A microcontroller’s I/O pin cannot sink this much of current, so external transistor arrays are required. I am using ULN2003A IC which has seven built-in Darlington transistor arrays (see below). The inputs of ULN2003A are active high. This means the input pins must be supplied with logic high in order to bring the corresponding output pins to ground. The schematic of the Darlington transistor array inside the ULN2003A chip is shown below.

 
In my project i have used transistors as drivers since ULN ic was not available to me during the project.


project images in RND-KC labs:-











code:-



#include<reg51.h>
sbit s1=P3^0;
sbit s2=P3^1;
sbit s3=P3^2;
void delay(unsigned int);
int r();
int n();
int d();
int dash();
int k();
int c();
void main(void)
{
P0=0x00;
P1=0x00;


 while(1)
{
P3=0x00;
s3=1;
r();
delay(1000);


P3=0x00;
s2=1;
r();


P3=0x00;
s3=1;
n();
delay(1000);



P3=0x00;
s1=1;
r();


P3=0x00;
s2=1;
n();


P3=0x00;
s3=1;
d();
delay(1000);




P3=0x00;
s1=1;
n();


P3=0x00;
s2=1;
d();


P3=0x00;
s3=1;
dash();
delay(1000);




P3=0x00;
s1=1;
d();


P3=0x00;
s2=1;
dash();


P3=0x00;
s2=1;
k();
delay(1000);


P3=0x00;
s1=1;
dash();


P3=0x00;
s2=1;
k();


P3=0x00;
s3=1;
c();
delay(1000);


P3=0x00;
s1=1;
k();


P3=0x00;
s2=1;
c();


P3=0x00;
delay(1000);


P3=0x00;
s1=1;
c();


P3=0x00;




}
}




int r()
{
  P0=0x00;
  P1=0x01;


  P0=0x66;
  P1=0x02;


  P0=0x56;
  P1=0x04;


  P0=0x39;
  P1=0x08;
return(0);
}
int n()
{
  P0=0x00;
  P1=0x01;


  P0=0x7B;
  P1=0x02;


  P0=0x6F;
  P1=0x04;


  P0=0x00;
  P1=0x08;
return(0);  
}
int d()
{
  P0=0x00;
  P1=0x01;


  P0=0x3E;
  P1=0x02;


  P0=0x5D;
  P1=0x04;


  P0=0x63;
  P1=0x08;
return(0);
}
int dash()
{
  P0=0x77;
  P1=0x01;


  P0=0x77;
  P1=0x02;


  P0=0x77;
  P1=0x04;


  P0=0x77;
  P1=0x08;
return(0);
}
int k()
{
  P0=0x00;
  P1=0x01;


  P0=0x6B;
  P1=0x02;


  P0=0x59;
  P1=0x04;


  P0=0x3E;
  P1=0x08;
return(0);
}
int c()
{
  P0=0x63;
  P1=0x01;


  P0=0x5D;
  P1=0x02;


  P0=0x3E;
  P1=0x04;


  P0=0x3E;
  P1=0x08;
return(0);
}
void delay(unsigned int x)
{
int i,j;
for(i=0;i<=x;i++)
{
for(j=0;j<=1275;j++) ;
}
}



video:-





I hope you all must have enjoyed the stuff and got the clear idea of dot matrix interface with the 8051 micro-controller..If  you have any doubt please post it,i'll try to resolve it..



THANK YOU

                                                     






9 comments:

  1. Which compiler has to be used to create .hex file of this code..??????

    ReplyDelete
  2. I had used KEIL IDE for compiling.

    ReplyDelete
  3. Thanx a lot Rahul..
    n can u let me kno which type of Matrix display u used, whether it was (ROW-ANODE COLUMN-CATHODE) or (ROW-CATHODE COLUMN-ANODE..????
    I am using (ROW-ANODE COLUMN-CATHODE) type of display..
    n also let me kno which port is driving row and which is driving column???
    I'l be grateful to u if u mail me some more related help on this email id: jinesh6591@yahoo.co.in

    ReplyDelete
  4. Pardon me,
    I am using (ROW-CATHODE COLUMN-ANODE)

    ReplyDelete
  5. sorry friend for late replay...i used (ROW-ANODE COLUMN-CATHODE)matrix...i think i had used port 3 for column and used it for all the displays..rest of the port were used for rows for each of the displays...i think u should refer my code for further proceedings if u have any prob...

    ReplyDelete
  6. hey can i get its schematic file ?
    pls mail me
    nrjchopra@gmail.com

    ReplyDelete
  7. plz mail me the schematic....

    waqas_khan661@yahoo.com

    ReplyDelete
  8. plz explain the ports ,u r using

    ReplyDelete
  9. hey can i get its schematic file ?
    pls mail me
    prabhukiran54@gmail.com

    ReplyDelete