All Characters on my LCD dont show, need Help

Discussion in 'Embedded Systems and Microcontrollers' started by Ebuka, Dec 10, 2010.

  1. Ebuka

    Thread Starter New Member

    Dec 8, 2010
    10
    0
    Hello ,
    Am using an 8051 uController to write to an LCD. Everything about the display is ok with me except that the cursor skips three character spaces before writing. Also only about 14 characters out of a string of 40 is shown. What can I do to get back on track.

    thanks.....
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Have you ever written to an LCD successfully?

    Can you step through the code in simulation/debug mode to see what signals are being sent to the LCD?

    LCDs are sometimes picky on timing, but if you've gotten past the init, that shouldn't be an issue.

    What language are you using? Post the applicable source code.

    I'm more of a PIC guy, but can hum a few bars in 8051, esp. if in C.
     
    Ebuka likes this.
  3. Ebuka

    Thread Starter New Member

    Dec 8, 2010
    10
    0
    My codes are below,
    Thanks for your support.

    Code ( (Unknown Language)):
    1.  
    2.  
    3. #include <REGX52.H>
    4.     #include <string.H>
    5.  
    6. #define LCD_data P2        // Data will be sent to/recieved from the LCD throught this port P2
    7. #define LCD_rs P1_0       // Select commd. register  0 = Instruction input        1 = Data input
    8. #define LCD_rw P1_1       //0 = Write to LCD module     1 = Read from LCD module
    9. #define LCD_en P1_2       //  Enable Signal
    10. #define LCD_D7 P1_7       // Busy Flag........
    11. #define LINE1 0x80
    12. #define LINE2 0xC0
    13.  
    14.  
    15. void LCD_Power_on(void);
    16. void LCD_Initialize(void);
    17. void LCD_Busy(unsigned int A);
    18. void Wait_For(unsigned int sec);
    19. void LCD_Get_signal(unsigned char signal);
    20. void LCD_Send_signal(unsigned char *signal,unsigned int max,unsigned char strt_on_linex);
    21. void LCD_Clear_line(unsigned char line);
    22. void LCD_string(char *senpoint, char Line);
    23. void LCD_toggl(void);  // Enable H->L make a high to low pulse
    24.  
    25. void main (void)
    26. {
    27. int a;
    28. unsigned char  message[] ="Hello every body, hope you all had a wonderful day. Welcome";
    29.               LCD_Power_on();
    30.               LCD_Initialize();
    31.               LCD_Get_signal(LCD_data);
    32. a = strlen(message);
    33.               LCD_Send_signal( message, a,LINE1);
    34.  
    35. }
    36.  
    37. // Initialization of LCD........................
    38. void LCD_Power_on(void)
    39. {
    40. int a;
    41. for(a=0;a<25000;a++);
    42. }
    43. void LCD_Initialize(void)
    44. {
    45.  LCD_data = 0x38;
    46.   LCD_Busy(0);          // Enable H->L make a high to low pulse
    47.  Wait_For(200);
    48.  LCD_data = 0x0F;
    49.   LCD_Busy(0);          // Enable H->L make a high to low pulse
    50.  Wait_For(200);
    51.   LCD_data = 0x01;
    52.   LCD_Busy(0);
    53.  Wait_For(200);
    54.   LCD_data = 0x06;
    55.  LCD_Busy(0);
    56.  Wait_For(200);
    57.  
    58. }
    59.  
    60. void Wait_For(unsigned int sec)
    61. {
    62. unsigned char i,j;
    63.         for(i=0;i<sec;i++)
    64.                 for(j=0;j<50;j++);
    65. }
    66.  
    67. void LCD_Busy(unsigned int A)
    68. {
    69.      LCD_rs   = A;        //Selected command register                        
    70.      LCD_rw   = 0;        //We are reading
    71.      LCD_toggl();                         // Read the Busy Flag...
    72.      
    73.      }
    74.  
    75.  void LCD_toggl(void)
    76. {
    77. //This is our toggle E line function to
    78. //tell lcd to accept data
    79.     LCD_en=1;    
    80.     LCD_en=0;    
    81. }
    82.  
    83. void LCD_Get_signal(unsigned char signal)
    84. {
    85. LCD_data = signal;
    86. LCD_Busy(1);
    87. Wait_For(250);
    88. }
    89.  
    90. void LCD_Send_signal(unsigned char *signal,unsigned int max,unsigned char strt_on_linex)
    91. {
    92. int i;
    93.  Wait_For(200);
    94.  
    95. LCD_data = strt_on_linex;
    96. LCD_Busy(1);
    97.  Wait_For(200);
    98. for(i=0;i < max;++i){
    99. Wait_For(200);
    100.  LCD_data = signal[i];
    101.  LCD_Busy(1);
    102.  Wait_For(200);
    103.  Wait_For(200);
    104. Wait_For(200);
    105.  
    106.  
    107. if(i == 0x93 || i == 18){
    108.  LCD_data = LINE2;
    109. LCD_Busy(0);
    110. Wait_For(200);
    111. }
    112. else if( i== 34){
    113. LCD_data = 0x01;
    114. LCD_Busy(0);
    115. Wait_For(200);
    116. }
    117.  
    118.  
    119.  
    120. }
    121. }
    122.  
    123. [/i]
     
    Last edited by a moderator: Dec 11, 2010
  4. Ebuka

    Thread Starter New Member

    Dec 8, 2010
    10
    0
    In my LCD_send_signal function definition, i tried moving the last 24 characters to the 2nd lime but doesn't work as espected.
     
  5. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    This part:
    Code ( (Unknown Language)):
    1.  
    2. void LCD_toggl(void)
    3. {
    4. //This is our toggle E line function to
    5. //tell lcd to accept data
    6.     LCD_en=1;    
    7.     LCD_en=0;    
    8. }
    9.  
    Shouldn't there be a delay between the two port changes? The LCD may not respond that fast.

    Also, can you step through and simulate to see if data is being written out to the LCD (or virtual LCD if you have one in the IDE)?
     
    Ebuka likes this.
  6. Ebuka

    Thread Starter New Member

    Dec 8, 2010
    10
    0
    my problem really is moving the last 24 characters in the first line of the LCD to the second line and vice-vasa, this is because i am using a 16x2 LCD and the last 24 characters cant show on the first line.

    Pls do help.
    Thanxs..........
     
  7. Ebuka

    Thread Starter New Member

    Dec 8, 2010
    10
    0
    I wait patiently for help.
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,019
    If I understand you correctly. You have 24 characters total but 16 characters on each line of the lcd.

    You then want to display 16 characters on one line then 8 characters on the 2nd line?


    Any reason you have to use assembler? This would be fairly easy to do in C or BASIC.
     
    Ebuka likes this.
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    This line in function main():

    You may want to test to see if a is longer than 16, if so, break it into line 1 and line 2.
    Code ( (Unknown Language)):
    1.  
    2. a = strlen(message);
    3.               LCD_Send_signal( message, a,LINE1);
    4.  
     
    Ebuka likes this.
Loading...