Popular Posts

Saturday, July 23, 2011

My First Attempt towards creating a 5 X 7 LED Matrix display

The  main  problem  related  with  this  circuit  is  the  absence of  the  input  side  and  the  absence  of 
 a  circuit  for  resetting  the  microcontroller.  The  circuit  may  function  well  in  simulation (I' ve  done  the  simulation  in  Proteus  I S I S). But  when  put  into  practice  the  circuit  may  be  difficult,  especially  when  one  is  taking  a single  side  P C B ( Printed  Circuit  Board )  layout ( presence of O R  Gates -Running  the  Gate  Swap  Optimizer  may  provide  a  small  solution )  and  also  from  programming  the MicroController.  The  controller  has  to  be  taken  to  be  taken  in  and  out  of  the  board,  essentially  damaging  the  board.

Circuit for Ring/Johnson Counter

330  ohms  resistor  should  be  used  instead  of  the  10K  resistances  given  in  the  figure.
 

The  oscillator  capacitors  should  have  a  value  of  22/33  p F  instead   of  the  1 n F  given  in  the  figure.

Oscillator  Frequency  must  be  set  to  20 MHz.

Improved circuit with Input side and Reset.

This modified circuit has the following changes:
An Input side which consists of a 7805 voltage regulator, input connector J1, an ICSP connector, J2 for programming the PIC without removing it from the PCB(which in turn avoids a lot of soldering work) and a reset connector, J3 for resetting the microcontroller.

SIL (Serial In Line) connectors are used for this purpose.

The ULN 2003A is a high current Darlington Array used to drive the LED matrix.

The PIC Microcontroller may provide current upto a few milli-amperes, it may be sufficient for driving a few LEDs but in case of a 5 X 7 LED Matrix, there are 35 LEDs and hence the drive current provided may be low. Hence the ULN 2003A current driver IC is used for this purpose.

While running the simulation I found that the output of the ULN was not changing and hence the Matrix Display was not working properly. The idea of the OR Gates then came into picture ( The working of the matrix display and the uselessness of OR gates will be explained later). The presence of the OR gates made the simulation work well.

However the difficulty of OR gates comes into picture while taking a single side PCB layout.

Real View of a 5 X 7 LED Matrix






This is the original view of a 5 x 7 LED Matrix.
Though called a 5 X 7 matrix display, it has 14 Pins.
Two or more of these pins come in common, thus creating 14 pins.
The LED matrix can be of two types
* Common Anode type
*Common Cathode type
The programming logic has to be changed depending on the type used
For larger displays, a number of such matrices are joined together and the required drive currenty is obtained using current driver ICs and transistors.
The pins of the matrix given in the figure are not in proper order. Hence if the PCB routing (taking the PCB layout) is done well, the complexities involved in te wiring can be avoided.
The first and eigth pin can be found out by wiring the circuit in a bread-board using a 5 V supply and series resistance of 330 ohms or 470 ohms.

Working of a 5 X 7 LED Matrix Rolling Display

A 5 X 7 matrix display works on the principle of persistence of vision. A letter displayed on the Dot Matrix display is actually not displayed as a whole. Actually each part is displayed for a fraction of a second and its turned off. The persistence of vision for human eye is 1/24th of a second. Hence the scanning of the matrix is done at a rate equal to or faster than this rate and the viewer gets an apparent illusion that the whole letter is displayed as a whole. The divided segment of the letter H is shown in the figure.





Each of the part is displayed for a fraction of a second and turned off, thus giving the appearance of the letter H. The movement i.e scrolling is made into effect by the use of shift registers.

Further Improvements made to the circuit

The LED Matrix however cannot be mounted on the main board ie along with the PIC, ULN and the latch.
Hence the main board will have to be provided with SIL ( Serial Inline Connentions ) to take the connections and provide it to the LED matrix which will be placed on another board ( PCB) .

PCB Layout of the main board with PIC and the input side

The following picture shows the PCB layout taken with the help of PROTEUS ARES PCB LAYOUT







continued.. (improvements)

Further, for the ease of taking the PCB layout and making the PCB more compact, the circuit was decided to be split up into 3 or 4 boards ( 3 without Keypad). The PCB and its input side was kept on one board and the other components were put up on another board.

The ciruit connections are as shown. The main board is provide with  7-pin and 8-pin SIL connectors to provide connections to the next board. Three separate connections for ground and Vcc, to take connections from it, in case the further boards developed doesn't have the ground and Vcc.

My General PIC Board... Port B and Port D can be used by anyone for any Purpose....

The use of the current driver IC ULN 2003A posed a problem on whether it would help the cause of scanning process of the LED Matrix. Hence  the board was decided to be split up into two, the main PIC Board and the Driver board (constituting the Latch-74373 and ULN 2003A). 
The PIC Board consists of PIC 16F877A, crystal oscillators, 7805 regulators, SIL Connectors and an ICSP (In Circuit Serial Progaramming) connector.

My General PIC Board continued..........


The program code for displaying the scrolling word ' HELLO' is given below. The program given below was compiled in PIC-C Compiler. The Hex File produced as a result of compiling the source file given below had a size of about 7K. The Program Flash Memory of PIC 16F877A is 8K x 14 words.

#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=20000000)

   void ENABLE()
   {
    output_low(PIN_C0);
   }
   void DISABLE()
   {
    output_high(PIN_C0);
   }
   void LATCH()
   {
    output_high(PIN_C1);
   }
     void COL_CONTROL_H(int i)
  {
   if(i==0)
   {
    output_high(PIN_D0);   
   }
   else if(i==1)
   {
    output_high(PIN_D1);
   }
   else if(i==2)
   {
    output_high(PIN_D2);
   }
   else if(i==3)
   {
    output_high(PIN_D3);
   }
   else if(i==4)
   {
    output_high(PIN_D4);
   }
   else if(i==5)
   {
    output_high(PIN_D5);
   }
   else if(i==6)
   {   
    output_high(PIN_D6);
   }
  }
  void COL_CONTROL_L(int i)
  {
   if(i==0)
   {
    output_low(PIN_D0);   
   }
   else if(i==1)
   {
    output_low(PIN_D1);
   }
   else if(i==2)
   {
    output_low(PIN_D2);
   }
   else if(i==3)
   {
    output_low(PIN_D3);
   }
   else if(i==4)
   {
    output_low(PIN_D4);
   }
   else if(i==5)
   {
    output_low(PIN_D5);
   }
   else if(i==6)
   {   
    output_low(PIN_D6);
   }
  }
    void ROW_5H()
   {
    output_high(PIN_C2);   
   }
   void ROW_4H()
   {
    output_high(PIN_C3);
   }
   void ROW_3H()
   {
    output_high(PIN_C4);
   }
   void ROW_2H()
   {
    output_high(PIN_C5);
   }
   void ROW_1H()
   {
    output_high(PIN_C6);
   }
   void ROW_5L()
   {
    output_low(PIN_C2);   
   }
   void ROW_4L()
   {
    output_low(PIN_C3);
   }
   void ROW_3L()
   {
    output_low(PIN_C4);
   }
   void ROW_2L()
   {
    output_low(PIN_C5);
   }
   void ROW_1L()
   {
    output_low(PIN_C6);
   }
   void DELAY_SS()
   {
      DISABLE();
      delay_us(250);
     ENABLE();
      delay_us(250);
   } 
   void CHAR_MAP()
   {
    int i=0,j;
    while(1)
    {
    for(i=0;i<25;i++)
    {
     /*
     //A
     COL_CONTROL_L(i);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     delay_us(50);
     COL_CONTROL_L(i+1);
     ROW_5H();
     ROW_3H();
     delay_us(50);
     COL_CONTROL_H(i+1);
     ROW_5L();
     ROW_3L();
     delay_us(50);
     COL_CONTROL_L(i+2);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i+2);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     delay_us(50);
     DELAY_SS();

     //B
     COL_CONTROL_L(i);
     ROW_1H();
     ROW_2H();
     ROW_3H():
     ROW_4H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i);
     ROW_1L();
     ROW_2L();
     ROW_3L():
     ROW_4L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i+1);
     ROW_1H();
     ROW-3H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i+1);
     ROW_1L();
     ROW-3L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i+2);
     ROW_2H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i+2);
     ROW_2L();
     ROW_4L();
     delay_us(50);
    
     DELAY_SS();
    
     //C
    
     COL_CONTROL_L(i);
     ROW_2H();
     ROW_3H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i);
     ROW_2L();
     ROW_3L();
     ROW_4L();
     delay_us(50);
     COL_CONTROL_L(i+1);
     ROW_1H();
     ROW_5H();
     delay_us(50);
     COL_OCNTROL_H(i+1);
     ROW_1L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i+2);
     ROW_1H();
     ROW_5H();
     delay_us(50);
     COL_OCNTROL_H(i+2);
     ROW_1L();
     ROW_5L();
     delay_us(50);
    
     DELAY_SS();
    
     //D
     COL_CONTROL_L(i);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     ROW_5H();
     */
    
    
     //H
     COL_CONTROL_L(i+2);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i+2);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i+1);
     ROW_3H();
     delay_us(50);
     COL_CONTROL_H(i+1);
     ROW_3L();
     delay_us(50);
     COL_CONTROL_L(i);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     ROW_5L();
     delay_us(50);
    
     DELAY_SS();
    
     //E

      COL_CONTROL_L(i-2);
      ROW_1H();
      ROW_2H();
      ROW_3H();
      ROW_4H();
      ROW_5H();
      delay_us(50);
      COL_CONTROL_H(i-2);
      ROW_1L();
      ROW_2L();
      ROW_3L();
      ROW_4L();
      ROW_5L();
      delay_us(50);
      COL_CONTROL_L(i-3);
      ROW_5H();
      ROW_3H();
      ROW_1H();
      delay_us(50);
      COL_CONTROL_H(i-3);
      ROW_5L();
      ROW_3L();
      ROW_1L();
      delay_us(50);
      COL_CONTROL_L(i-4);
      ROW_5H();
      ROW_3H();
      ROW_1H();
      delay_us(50);
      COL_CONTROL_H(i-4);
      ROW_5L();
      ROW_3L();
      ROW_1L();
      delay_us(50);
     
      DELAY_SS();
           
     //L
    
     COL_CONTROL_L(i-6);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i-6);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i-7);
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-7);
     ROW_1L();
     delay_us(50);
     COL_CONTROL_L(i-8);
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-8);
     ROW_1L();
     delay_us(50);
    
     DISABLE();
     delay_us(650);
     ENABLE();
    
     DELAY_SS();
    
     //L
    
     COL_CONTROL_L(i-10);
     ROW_1H();
     ROW_2H();
     ROW_3H();
     ROW_4H();
     ROW_5H();
     delay_us(50);
     COL_CONTROL_H(i-10);
     ROW_1L();
     ROW_2L();
     ROW_3L();
     ROW_4L();
     ROW_5L();
     delay_us(50);
     COL_CONTROL_L(i-11);
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-11);
     ROW_1L();
     delay_us(50);
     COL_CONTROL_L(i-12);
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-12);
     ROW_1L();
     delay_us(50);
    
    
   
     //O
     COL_CONTROL_L(i-14);
     ROW_2H();
     ROW_3H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i-14);
     ROW_2L();
     ROW_3L();
     ROW_4L();
     delay_us(50);
     COL_CONTROL_L(i-15);
     ROW_5H();
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-15);
     ROW_5L();
     ROW_1L();
     delay_us(50);
     COL_CONTROL_L(i-16);
     ROW_5H();
     ROW_1H();
     delay_us(50);
     COL_CONTROL_H(i-16);
     ROW_5L();
     ROW_1L();
     delay_us(50);    
     COL_CONTROL_L(i-17);
     ROW_2H();
     ROW_3H();
     ROW_4H();
     delay_us(50);
     COL_CONTROL_H(i-17);
     ROW_2L();
     ROW_3L();
     ROW_4L();
     delay_us(50);

     DELAY_SS();
    }   
    }
   }


void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
   ENABLE();
   COM();
   LATCH();
   CHAR_MAP();

}

Driver Borad.................

Consists of High current driver ULN 2003A and latch 74LS373( LS: Low Power Schottky)....... The Driver IC meets the current requirement of the LED Matrix while the 74373 enables data latching.




Connected Circuit

The PIC board, the driver board are interconnected as shown ...
The PCBs are interconnected using SIL connectors ... use of good quality SIL connectors are recommended, more due to my personal experience.


Testing of the circuit .

The final circuit can be tested by making the ports of the PIC corresponding to that of all rows and columns of the LED matrix high or low depending on the program logic. A few images of the test are given below. The third image was actually a test for making all the pins of the LED matrix high, but the poor quality of the SIL connectors prevented it .





Final circuit ...

This was the final circuit put up for demonstration ...