+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Newbie level 4
    Points: 311, Level: 3

    Join Date
    Oct 2013
    Posts
    5
    Helped
    0 / 0
    Points
    311
    Level
    3

    lcd is working in proteus but not working in hardware, UC is AT89c51

    lcd JHD 162A is working in proteus but not working in hardware, we are using Atmel AT89C51 microcontroller. The display occurs momentarily sometimes(rarely 1 or 2 times) but again the LCD turns back into showing bars. We've tried several methods like using simple programs for displaying "Hello" , "WALLE" etc. But again the same problem.

    Here's the code for displaying "WALLE"

    Code:
    #include
    #define RS P1_7
    #define RW P1_6
    #define EN P1_5
    #define DATA P2
    
    void delay(int n);
    void ins(void);
    void dat(void);
    void latch(void);
    
    void main(void)
    {
    		   	
    	 int k=0;
    	 char x[6]="WALLE";
    	 
    		
                 
                 delay(100000);
                 ins();
                 DATA=0X38; //8-bit Databus, Set 2 lines, and Select font size 5x7
                 latch();
                 DATA=0X0F;// It will display the characters, will display the cursor and it will blink.
                 latch();
                 DATA=0X10; // Set cursor on line 1. Use 0xC0 to write on line 2.
                 latch();
                 DATA=0X0; //Before changing to write data select. Make port 2 =0x0 so that LCD receives nothing
    			 dat();
    			 latch();
                 for(k=0;k<=5;k++)
                 {
                             DATA=x[k];
                             latch();
                 }
    			 while(1);
             
    	  
    
               
    }
    
    void delay(int n)
    {
     int i=0,j=0;
     for(i=0;i<=n;i++)
     for(j=0;j<=10;j++);
    }
    
    void ins(void) //Instruction select routine
    {
                 RS=0;
                 RW=0;
    }
    void dat(void) // Data select routine
    {
                RS=1;
                RW=0;
    }
    void latch(void) // Latch routine
    {
                EN=1;
                delay(1000);
                EN=0;
                delay(1000);
    }
    Diagram is given here:



    http://obrazki.elektroda.pl/1332797100_1382441491.gif
    Last edited by alexan_e; 23rd October 2013 at 09:15. Reason: added CODE tags

    •   AltAdvertisement

        
       

  2. #2
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    830 / 830
    Points
    23,048
    Level
    36

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    ins();
    DATA=0X38; //8-bit Databus, Set 2 lines, and Select font size 5x7
    latch();
    ins();
    DATA=0X0F;// It will display the characters, will display the cursor and it will blink.
    latch();
    ins();
    DATA=0X10; // Set cursor on line 1. Use 0xC0 to write on line 2.
    latch();
    ins();
    DATA=0X0; //Before changing to write data select. Make port 2 =0x0 so that LCD receives nothing
    latch();
     
    for(k=0;k<=5;k++)
    {
    dat();
    DATA=x[k];
    latch();
    }
    Last edited by jayanth.devarayanadurga; 22nd October 2013 at 12:54.



  3. #3
    Full Member level 3
    Points: 1,278, Level: 8
    mathespbe's Avatar
    Join Date
    Jul 2013
    Location
    India, Tamilnadu, Coimbatore
    Posts
    186
    Helped
    45 / 45
    Points
    1,278
    Level
    8

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    Use proper delay... Dely must be the problem here...



    •   AltAdvertisement

        
       

  4. #4
    Full Member level 6
    Points: 2,879, Level: 12
    Achievements:
    7 years registered

    Join Date
    Oct 2011
    Location
    surat
    Posts
    395
    Helped
    22 / 22
    Points
    2,879
    Level
    12

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    i think your circuit diagram is wrong . because JHD 162A has pin no. 4 , 5 , 6 is RS , RE , E is connected to the micro-controller pin no 10,11 and 16 which is PORT3 of 89c51 and in your code u mentioned port 1 something wrong or not?



  5. #5
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    830 / 830
    Points
    23,048
    Level
    36

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    Yes. pin connections are wrong. Have to put a resistor on pin 15 or 16.

    Code C - [expand]
    1
    2
    3
    
    #define RS P3_0
    #define RW P3_1
    #define EN P3_6



  6. #6
    Full Member level 5
    Points: 2,342, Level: 11
    Jigar 4 Electronics's Avatar
    Join Date
    Apr 2011
    Location
    Hamilton, ON, Canada
    Posts
    313
    Helped
    40 / 40
    Points
    2,342
    Level
    11
    Blog Entries
    2

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    It should be like this:

    Click image for larger version. 

Name:	LCD_8051_ckt.JPG 
Views:	11 
Size:	108.3 KB 
ID:	97623
    Never Leave it until you did it.
    Every time you fails go for one more time :)



    •   AltAdvertisement

        
       

  7. #7
    Newbie level 4
    Points: 311, Level: 3

    Join Date
    Oct 2013
    Posts
    5
    Helped
    0 / 0
    Points
    311
    Level
    3

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    Thanks for your suggestion, will implement it.

    what might be the proper time delay for this uC, and how to calculate the time delay ?



  8. #8
    Junior Member level 3
    Points: 294, Level: 3

    Join Date
    Oct 2013
    Posts
    31
    Helped
    4 / 4
    Points
    294
    Level
    3

    Re: lcd is working in proteus but not working in hardware, UC is AT89c51

    2 ms will be good...
    Last edited by ratheeshvaram@yahoo.com; 23rd October 2013 at 12:02.



--[[ ]]--