display lcd problem black square

Discussion in 'Embedded Systems and Microcontrollers' started by MED_TN, Feb 22, 2013.

  1. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    Hi.
    my program function well in ISIS proteus but in the real life it dosen't, the problem thats a have in the first line many black square.
    i use a 4 bits configuration and 18f4550 pic.
    thats my program please help me.
    sorry for my bad level of english thats my first time in this forum.


    Code ( (Unknown Language)):
    1.  
    2. sbit LCD_RS at LATB0_bit;
    3. sbit LCD_EN at LATB1_bit;
    4. sbit LCD_D4 at LATB2_bit;
    5. sbit LCD_D5 at LATB3_bit;
    6. sbit LCD_D6 at LATB4_bit;
    7. sbit LCD_D7 at LATB5_bit;
    8.  
    9. // Pin direction
    10. sbit LCD_RS_Direction at TRISB0_bit;
    11. sbit LCD_EN_Direction at TRISB1_bit;
    12. sbit LCD_D4_Direction at TRISB2_bit;
    13. sbit LCD_D5_Direction at TRISB3_bit;
    14. sbit LCD_D6_Direction at TRISB4_bit;
    15. sbit LCD_D7_Direction at TRISB5_bit;
    16.  
    17.  
    18. /****************************Programme Principal*********************/
    19.  
    20. void main()
    21. {
    22.  
    23. TRISA=0x00;
    24. TRISB=0x00;
    25. PORTB.f0=0;
    26. PORTA=0xFF;
    27. delay_ms(1000);
    28. Lcd_Init();
    29. Lcd_Cmd(_LCD_CLEAR);
    30. Lcd_Cmd(_LCD_CURSOR_OFF);
    31.  
    32. delay_ms(500);
    33. Lcd_Out(1,1,"bonjour");
    34. delay_ms(500);
    35. LCD_out(2,2,"Salut");
    36. delay_ms(500);
    37. }
    38.  
    39.  
    i put the third pin (3) of the LCD in the GND i didn't use a pot and (do you think thats not wrong ??)
    also i I connected RW pin to Ground because i use the lcd only to write things and i see in others forum that it is wrong and i must connect R/W to a pin of the pic. thats true ????
    and if i must do it what i must change in my program
    I use MIKROC pro for pic
    Thx
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    One post is enough!
     
  3. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    sorry
    but i wont to change mu subject to Embedded Systems and Microcontrollers forum
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    Ask a mod to do that for you next time.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    The first line with black squares means that the LCD is not initialized properly.
    Check:
    1) All wiring to the LCD,
    2) Make sure you have a 0.1μF capacitor between VCC and GND at the LCD pins,
    3) Check software timing,
    4) Double check your code.
     
    MED_TN likes this.
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    Hi Med, nice to see you in this forum.

    Do you have a schematic of your setup you can post? If you need help on software to draw that we can help there too, but any sort of sketch will do, even scanned pencil on paper or a bitmap sketch.
     
  7. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    Thx to you for your help.

    thats my schematic and i use the intern oscillatateur of the pic

    [​IMG]
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,018
    Did you verify your connections by testing each bit at the LCD?

    You should tie D0 - D3 low.
     
  9. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    yes i verified my connection by usung a voltmetre sonore "bip" if connection is well.

    do you think i must put D0-D3 to the ground ??
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    No those bit are dont care during the setup phase.
     
  11. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    thats the table of the datacheet of the LCD : V0 it is the pin of the contrast

    [​IMG]
     
  12. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    when i did the calcul with this table i must have V0 between 0.8 v and 0.2 v and me i put it in the ground.
    Do you thinks thats wrong
     
  13. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    VEE pin-3 on the LCD is usually the contrast control.
    On my LCD, if VEE is connected to VDD I get a blank screen.
    VEE connected to VSS gives darkened boxes. Text is visible with poor contrast.
    I normally connect VEE to VSS via a 1kΩ resistor.
     
  14. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1

    i was rong in my posted shematin me i connected VEE to the Ground but the thing which i dont understand it thas i have Black Square only in the first row, in the second row i dont have any thing it is blank!!!!!!!!!!

    in the datasheet VEE must be between 0.2 v and 0.8 v and me i put it in the ground (0 v) i will try to use a potentiometre and see what will hapen
     
  15. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    Read my post #5.
    Black squares on the first line means that the LCD is not initialized.
     
  16. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,018
    What is "sonore bip"? Did you check continuity or did you actually check the transition of each bit? You can write a test program to verify one bit at a time. first setting it high then low. Step through your program and verify that each bit changes as excepted.

    Yes you should ground each bit. You should also add a pot on the contrast pin.
     
  17. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    yes i checked continuity and it is ok.
    and i checked a program to turn on a LED and it is ok.
    i checked voltage in pins of the LCD and are ok.
     
  18. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    yes i readed your post and all says that is a problem of initialized or of contrast.
    you say that my LCD is not initialized but i put LCD_init() !!!!!

    so what i must correct in my program , do you think i must put dela_ms(1000) before LCD_inti() !!!!

    please if you can say to me what can be wrong in my intialisation.
    THX
     
  19. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    once again YES put that delay there.

    Read my previous post.
     
    MED_TN likes this.
  20. MED_TN

    Thread Starter New Member

    Feb 21, 2013
    15
    1
    thx for all to help me.

    Please my LCD driver is 'SAMSUNG KS0070BP' is this driver compatible with HITACHI HD 44780 ????
     
Loading...