Lcd Problem

Discussion in 'General Electronics Chat' started by LAJ5, Dec 30, 2007.

  1. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    we bought a 16x2 LCD, it is functionally equivalent to industry standard Hitachi display.
    the problem is, when we supply 5v (with proper connections), only the first line has display.
    we also tried it in a 20x4 LCD, only the first and third lines has displays.
    what seems to be the problem???
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Here is a very good LCD display website.

    As for your specific problem, it sounds as though you may have a connection problem in your interface cable between the host and the display. It may be worth taking a bit of time to confirm that your cable is wired properly.

    One quick check would be to make sure that for the lines that are working that the correct character is displayed for the particular ASCII code written.

    hgmjr
     
  3. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    thanks.:)

    but i just supplied 5v. i haven't interfaced it yet.
    as far as i know, when you supply an LCD, all of the 5x7 matrix of both 2 lines would light up, as a sign that it is functioning.
    but, for us, only the 5x7 matrices of the first line light up. for the 2nd line, it doesn't.
    what seems to be the problem?

    **we had also tried interfacing it with an encore controller but it also did not displayed the desired output.maybe because of the problem i just mentioned above.

    thanks!
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Take a look at the information at the link I supplied earlier and you will see that there is a rather involved initialization sequence required before the LCD display is ready to operate predictably. Just applying power to the LCD is not sufficient to set the LCD up for normal operation.

    hgmjr
     
  5. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    ok.i will follow it.
    thanks!
    happy new year!:)
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Once you have initialized the display, make sure you handle the contrast input voltage correctly. It is easy to be fooled into thinking the LCD is not working when the only problem is that the contrast is not adjusted properly.

    hgmjr
     
  7. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    ok. we already had a program for initializing the LCD. we had also adjusted the contrast.
    and it still doen't displayed. i'm still trying to figure out the problem.
    thank you very much!:)
     
  8. WAN24

    Member

    Jun 27, 2006
    21
    0
    check your wirings and connections carefully, also,check the specs, supply the proper voltage.. maybe there's something wrong.. good luck my friend..
     
  9. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    sir hgmjr,
    the informations from the website is almost the same in our book and in our other references. again, i tried and it still doesn't work. i only followed the connections from the book(which is common in most of my references). the LCD is directly interfaced to the microcontroller. i assigned portA for data bits and portC for the RS, RW & EN. though i had already set the RW to zero, by connecting it to the ground. pin1 is for ground, pin2 is for +5V(VCC) and pin3 is for the contrast adjustment. QUESTION: is there any other external circuitry needed??? is there any lacking connection??
    the program provided by the book is appropriate/compatible for the microcontroller we are using which is z8encore1621. the program contains the initialization needed by the LCD and a test program for it to the display the phrase "hello world". but after several times, it still doesn't work.

    as i had said, i tried to supply it(with only pins 1,2&3 has connections). i also tried to interface it with the microcontroller(with the connections above and the program).
    but the result is the same for both conditions::eek:nly the 16-5x7 dots of the first line light up. for the 2nd line, not even one of the 16-5x7 had light up.

    thank you for the help. i really do appreciate it. :D
     
  10. LAJ5

    Thread Starter New Member

    Dec 11, 2007
    7
    0
    this is the program. sorry, i don't know how to convert it to a pdf file. :D

    /////LCD.h
    void LCD_init(void);
    void LCD_print(unsigned char *s);

    void LCD_write(unsigned char data, unsigned char RSflag);

    #define LCD_DATA 0x01
    #define LCD_INSTR 0x00
    #define LCD_INIT 0x80

    #define LCD_move(addr) LCD_write(0x80+addr, LCD_INSTR)
    #define LCD_home() LCD_write(0x02, LCD_INSTR)
    #define LCD_cursoroff() LCD_write(0x0C, LCD_INSTR)

    /////LCD.c
    #include <ez8.h>
    #include "lcd.h"

    void LCD_write(unsigned char data, unsigned char RSflag)
    {
    unsigned int i;

    PADD = 0x00; // write to LCD
    PCOUT = (RSflag & 0x01) + 0x04;
    PAOUT = data;
    PCOUT = (RSflag & 0x01);
    PADD = 0xFF; // read from LCD
    if (!(RSflag & 0x80))
    { // wait for busy flag
    PCOUT = 0x06;
    while (PAIN & 0x80) ;
    }
    else // 5ms delay
    for (i=0; i<0x0C00; i++) ;
    }

    void LCD_init(void)
    {
    unsigned int i;

    PCDD &= ~0x07; PCAF &= ~0x07; PCOC &= ~0x07;
    PAAF = 0x00; PAOC = 0x00;

    for (i=0; i<0x2400; i++) ; // 15 ms delay for controller warmup
    LCD_write(0x30, LCD_INIT); // set to 8-bit mode
    LCD_write(0x30, LCD_INIT);
    LCD_write(0x30, LCD_INIT);

    LCD_write(0x38, LCD_INSTR); // 8-bit mode, 2 lines, 5x7 dots
    LCD_write(0x08, LCD_INSTR); // display off, cursor off, blink off
    LCD_write(0x06, LCD_INSTR); // increment cursor, static display
    LCD_write(0x01, LCD_INSTR); // display clear
    LCD_write(0x0F, LCD_INSTR); // display on, cursor on, blink
    }

    void LCD_print(unsigned char * s)
    {
    while(*s)
    LCD_write(*s++, LCD_DATA);
    }

    /////LCD_DEMO.c
    #include <ez8.h>
    #include "lcd.h"

    void main(void)
    {
    LCD_init();
    LCD_home();
    LCD_print("hello world! ");
    }
     
  11. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I'll see if I can find anything amiss with your source code.

    Don't worry about not being able to get the source code into pdf format. What you have provided will do.

    EDIT: (added the following)

    I recommend that you start by simply attempting to write a single character to the LCD. There will be plenty of time to get all of the bells and whistles of your LCD_print routine operational once you have gained a bit of confidence by writing a few single characters to the display. You can write the location (line number and character position) in the display and then write the ascii value of the character you want to display.

    By taking smaller steps toward your goal of getting the LCD operational, you can minimize the number of things that you need to investigate in trying to track down your problem.

    hgmjr
     
Loading...