+ Reply to Thread
Results 1 to 11 of 11

Thread: LCD not working?

  1. #1
    mstechca Bad
    Join Date
    Mar 2003
    Location
    Why do you care?
    Posts
    1,598

    Default LCD not working?

    This has literally beaten me for the past two days.

    I hooked up the data pins of my hitachi controller compatible LCD to the data pins on the parallel port, and I hooked the parallel port's strobe pin to the clock pin on the LCD. I also connected a pull-up resistor to the strobe pin. The rest of the output parallel port pins are unused. The Busy, ack lines are set to ground, and the select printer pin is set high.

    I have the following as my qbasic program to drive the port:

    open "lpt1:" for output as #1
    print #1,chr$(63)
    print #1,chr$(15)
    close #1
    end

    The first instruction seems to execute perfectly every time, but the subsequent instructions dont want to work.

    I even tried to implement a one second delay between each print statement like this:

    open "lpt1:" for output as #1
    start=timer
    do
    loop until timer - start >= 1
    print #1,chr$(63)
    start=timer
    do
    loop until timer - start >= 1
    print #1,chr$(15)
    start=timer
    do
    loop until timer - start >= 1
    close #1
    end


    and it still doesnt want to work.

    this is why I wanted to do everything hardware based, where I can poll the busy flag on my LCD.

    Can someone tell me what is going on?


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,783

    Default

    It doesn't look anywhere near enough to drive an LCD, they are quite difficult to get working. However, there are LOTS of examples of doing it from the parallel port on the net, try searching for case modifications.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    Exo
    Exo is offline
    Exo Newbie
    Join Date
    Sep 2003
    Location
    Belgium
    Posts
    1,884

    Default

    We need more information. Assuming you're talking about a HD44780 compatible character LCD:

    First of all post a full scematic on how you connected your LCD to the parallel port. I don't see any mention on where the LCD's R/W and RS pins are connected to.

    Also, Does the display show one line with all pixels lit when power is applied? (a line full of 'black boxes'). A HD44780 should do this, if not , you have a wrong connection on your power or contrast pins.
    Also note some LCD's need a negative voltage for contrast.

    Also, in software, you're going to have to do the output manually - The printing sequence of the parallel port is made for a printer, an lcd doesnt work with it. So you need to output data by bit banging it directly.

    Here's an overview of the LPT's data & control registers
    http://www.doc.ic.ac.uk/~ih/doc/par/doc/regpins.html

    The correct sequence for an LCD is (8bit Interface):
    -Put strobe high
    -Set RS line (0 =instruction, 1 =text)
    -Set R/W line (0 =write to lcd, 1 =read) You always want to write probably
    -Set data on data pins
    -Put strobe low
    You seem to have the 2 bytes to send for initialization correct. You need a third clear screen (0) command after that for it to work correctly.

  4. #4
    mstechca Bad
    Join Date
    Mar 2003
    Location
    Why do you care?
    Posts
    1,598

    Default

    I think mine is screwed now. When I set the interface length, it seemed OK, but when I tried to enable the LCD display with the curcor, it wouldn't show up. Is there some other command I need to issue first, or should I throw the LCD out?

  5. #5
    Exo
    Exo is offline
    Exo Newbie
    Join Date
    Sep 2003
    Location
    Belgium
    Posts
    1,884

    Default

    You are completely interfacing it wrong -
    Read my post above. Just connecting the LPT's strobe to the LCD's strobe and giving a print command doesn't work !

    The LPT's strobe is positive, a LCD's strobe should be negative, and the moment on wich is it given is incorrect too. You need to toggle the parallel port's line yourself by writing to the port's registers wich i gave in the link in my previous post.

    Like i asked before, if you apply power to the lcd, only power, no other things connected, does it show all pixels lit on the first line ?

  6. #6
    mstechca Bad
    Join Date
    Mar 2003
    Location
    Why do you care?
    Posts
    1,598

    Default

    Like i asked before, if you apply power to the lcd, only power, no other things connected, does it show all pixels lit on the first line ?
    yes

    Let's forget the fact that the parallel port appeared for a moment. How do I get text to appear on the LCD?

    I think it is damaged, because I applied a "1" to D0, D1, D2, and D3 lines, and a "0" to D4, D5, D6, and D7 lines, and I changed the "E" line from high to low, which is supposed to make the LCD turn the cursor on.

    For all my tests, the R/W line is low, the R/S line is also low.

  7. #7
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,783

    Default

    As has been mentioned various times in this thread, you seem to be treating it 'too simply', as I mentioned previously, there are many sites dealing with driving LCD modules from parallel ports (by case modifiers), you should try consulting those?. Or at least study the datasheets for the LCD's, and write your code accordingly - as it stands I'm not surprised it doesn't work!.

    If you're getting a line of solid blocks the LCD looks to be OK, but you're not setting it up correctly!.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  8. #8
    samcheetah Newbie
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    874

    Default

    try this

    Build your own printer cable LCD Display
    http://www.electronics-lab.com/proje...020/index.html

  9. #9
    Exo
    Exo is offline
    Exo Newbie
    Join Date
    Sep 2003
    Location
    Belgium
    Posts
    1,884

    Default

    Quote Originally Posted by mstechca

    Yes

    I think it is damaged, because I applied a "1" to D0, D1, D2, and D3 lines, and a "0" to D4, D5, D6, and D7 lines, and I changed the "E" line from high to low, which is supposed to make the LCD turn the cursor on.

    For all my tests, the R/W line is low, the R/S line is also low.
    First off all, if it shows the line of solid blocks the lcd is not damaged.
    Before you can turn the cursor on and other things you need to initialize the lcd by setting the interface length, number of lines, and font

    Set D7, D6 and D2 to 0. D5, D4 and D3 to 1 (D1 & D0 dont matter) and then give a high to low on the clock.

    This sets it to 8-bit IF , 2 line , 5 * 7 font lcd. Then you can try and send your cursor command.

  10. #10
    mstechca Bad
    Join Date
    Mar 2003
    Location
    Why do you care?
    Posts
    1,598

    Default

    Quote Originally Posted by Exo
    You need to initialize the lcd by setting the interface length, number of lines, and font

    Set D7, D6 and D2 to 0. D5, D4 and D3 to 1 (D1 & D0 dont matter) and then give a high to low on the clock.
    This is what I have exactly done after I first turn it on. What I get is a clear display.

    Then you can try and send your cursor command.
    When I tried setting the cursor command (D0 to D3 is 1, D4 to D7 is 0) and give a high to low on the clock, what it does is acts as if it shut doen for a split second and turn itself back on (1st line has blocks filled). This is why I think it is broken.

  11. #11
    kitedude Newbie
    Join Date
    Feb 2004
    Posts
    55

    Default

    are you including a header file

+ Reply to Thread

Tags for this Thread