Shop OBEX P1 Docs P2 Docs Learn Events
2x40 LCD — Parallax Forums

2x40 LCD

NewzedNewzed Posts: 2,503
edited 2005-06-02 18:35 in BASIC Stamp
I have a 2x40 LCD I'm having a few problems with.· Does any one know the starting cursor address for Lines 1 and 2.

Thanks

Sid

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 14:56
    I've run into a few oddballs so what I did is wrote a program that would sequetially loop through what I though were logical addresses and display a "*" on the LCD -- I did a clear in between each write to reset things. The address was output to the Debug Terminal and I simply wrote down the addresses I needed. It'll only take a minute to whip up the tester program; then it's having the patience to watch the program run (you could also insert a DEBUGIN in the loop so you can control each iteration).

    I would use $80 as the starting address.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 15:09
    Sid,

    ·· If you're talking about the LCDs I think you are, then the start address is $00 and the second line is $40.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 15:15
    Something like this, Jon:

    init:
    addr·= 128

    start:
    debug dec ? addr, cr
    gosub LCDCommand

    char = "*"
    gosub LCDWrite
    pause 1000
    addr = addr + 1
    debug "Press any key to continue", cr
    debugin com
    goto start

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 15:36
    Close -- give this a go:

    addr··· VAR··· Byte
    char··· VAR··· Byte
    com···· VAR··· Byte

    Reset:
    · addr = $80

    Main:
    · DO
    ··· char = LcdCls························ ' clear LCD·
    ··· GOSUB LcdCommand
    ··· PAUSE 2······························ ' do not remove -- LCD needs time
    ··· char = addr
    ··· GOSUB LcdCommand····················· ' position cursor
    ··· char = "*"
    ··· GOSUB LcdWrite······················· ' print *
    ··· DEBUG HOME, "Addr = ", IHEX2 addr···· ' display current address
    ··· addr = addr + 1·······················' point to next·
    ··· DEBUGIN com·························· ' get key
    ··LOOP UNTIL (com = "x")················· ' do again unless "x" pressed
    · END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 15:36
    Chris, I tried those addresses but it didn't help.· Are there any other "peculiarities" for the 2x40?



    Sid
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 15:50
    Sid,

    ·· I don't know what to tell you...Using the BS2p, I was able to address them the same as any other 2X40 using the standard Hitachi addresses of $00 for the first line, and $40 for the second line.· Those units were tested.· Although 2 or 3 required negative bias on the Vee line.· So I guess my question is, are you getting anything on the display at all?· If not, that's probably what's wrong.· You'll probably need between -0.5 and -1.5V on Vee.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 15:51
    Since you don't seem to be using a BS2p, Sid, are you sure your initialization sequence is correct? Are you getting anything on the LCD?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 15:57
    When I start the program I get nothing.· If I interrupt the LCD Vcc for a few seconds then restore it, I get a garbage display that shifts to the right one space each time the program cycles.

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 15:59
    I might add that the program works perfectly with a 2x20.· If I remove the 2x20, change the cursor address pointers for the 2x40, then plug the 2x40 in and reload,·nothing.



    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 16:04
    Chris, I do not have a negative supply, and I don't think there is a source on the PDB.· If I take a AA cell, connected the positive end to system ground and the negative end to Vee, would that work?

    Sid
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 16:09
    Sid,

    ·· I've never seen it done that way, but maybe...The problem is you won't know how much voltage until you start going negative from 0.· You don't want to go too far.· You should be sure you have the correct datasheet for the module.· If you can't find one, better safe than sorry.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 16:39
    Sid/All,

    ·· I realized my post above about LCD addresses might cause some confusion so I wanted to address that right now.· The addresses for the LCD are formed by assigning the 7-bit address ($00-$7F) to the command byte for writing data to the DDRAM.· Because of the way this is done on the BASIC Stamp the BUSY Flag isn't used by most of the code, and therefore we ignore BIT7.· During the writes to DDRAM BIT7 is always 1, so in that sense the actual value of the command sent will be from $80-FF.· Sorry for any confusion.

    ·· The same effect happens when addressing the RAM on the DS1302 RTC.· The actual byte sent will vary some depending on the actual address, which is only 5 bits.· But that address is encoded into the command byte for a read or write, meaning certain bits are alwats set.· I hope this explains things a little better.· If you don't understand the inner workings of the LCD, definately use Jon's code.· That stuff happens in the background and you don't have to worry about it.

    ·· My main thing was that when you look at LCD address maps, this is why they say $00 for the starting address, and why line 2 on 2 line displays is usually $40.· On 4 line displays things get a little weird because the lines are not addressed in order.· But rather line 1 is usually $00, line 2 is usually $40, line 3 is usually $20 and line 4 is usually $60.· On 4 X 40 line displays this gets even more complicated since there are actually 2 controllers and 2 enable lines.

    NOTE:· The above information applies to HD44780 or compatible modules.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 6/2/2005 4:53:17 PM GMT
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 17:19
    Chris, I have a 10K pot across 5VDC and ground with the wiper feeding Vee.· Suppose I remove the 5VDC· and hook a AA cell across the pot with the positive end of the cell to the ground connection of the pot.· Would that work better?

    Sid
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 17:20
    Sid,

    ·· Yes, you can try that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 17:36
    Jon, I tried the little cursor address program - very interesting.

    With the 2x20 I got Line 1 = 128, Line 2 = 168(addr changed but * did not advance), Line 2 = 192.· My program uses 128 and 192.· Changed 192 to 168 and program still worked perfectly.· Strangesmhair.gif

    I then tried it out with the 4x20 and got Line 1 = 128, Line 3 = 148, Line 2 = 192, Line 4 = 212.· These are the values I'm using in my current program.

    Tried it with the 2x40 - nothing.

    Thanks for the help - I'm sure I'll be using that program·many times·in the future.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 18:26
    I'm not terribly surprised at what you found.· I've been using these constants:

    LcdLine1······· CON···· $80···················· ' DDRAM address of line 1
    LcdLine2······· CON···· $C0···················· ' DDRAM address of line 2

    ... in my LCD programs for the last 10 years ($80 = 128, $C0 = 192).· Most character LCD driver chips, even the off-brands, comply with the Hitachi HD44780 spec (or come really close).

    I don't know how to explain the problems you're having with the 2x40; you don't see those around much, perhaps it's an odd duck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2005-06-02 18:35
    Jon. on the 2x40, it was the negative Vee.· I hooked a AA cell across my Vee pot with the positive end of the cell going to ground and now it works perfectly.·jumpin.gif

    Cursor addresses are $80 and $C0.

    Sid
Sign In or Register to comment.