Shop OBEX P1 Docs P2 Docs Learn Events
HD44780 LCD Help - Can't Display Characters — Parallax Forums

HD44780 LCD Help - Can't Display Characters

ndsbassndsbass Posts: 7
edited 2008-03-18 15:54 in BASIC Stamp
Hey guys quick LCD related question. I just recently bought a 2x16 hd44780 based LCD (datasheet: www.411techsystems.com/Ebay/Specs/SSC2F16DLNW-E.pdf and am using a basic stamp controller to operate it in 4 bit mode. Since this is my first real LCD project I have based 90% of my code off of the tutorial I found at www.weethet.nl/english/basicstamp2_lcdcontrol.php . I've got the LCD operational for the most part however my most recent problem is I cannot get the LCD to display any text.

Commands seem to be working just fine, however my LCD refuses to display any character I send at it. At first I figured that the RS line was still low when I was sending characters, but my multimeter proved otherwise. Strangely enough when using a cursor after sending a character the LCD will move the cursor one spot to the right as if I have sent a character, but no character appears. Here is the basic stamp code I am using:

' {$STAMP BS2}
' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
' Ports used
                 RS CON 4 ' Register Select (1 = char)
                 E CON 5  ' LCD Enable pin (1 = enabled)

' LCD control characters
'
                 ClrLCD CON $01 ' clear the LCD
                 CrsrHm CON $02 ' move cursor to home position
                 CrsrLf CON $10 ' move cursor left
                 CrsrRt CON $14 ' move cursor right
                 DispLf CON $18 ' shift displayed chars left
                 DispRt CON $1C ' shift displayed chars right
                 DDRam CON $80  ' Display Data RAM control

' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
'
                 char VAR Byte  ' character sent to LCD
                 x VAR Byte ' loop counter

' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
'
                 Msg DATA "BASIC Stamp 2 LCD in action"   ' preload message

' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
'
Init:            DIRL = %00111111   ' set pins 0-5 as outputs
                 OUTS = $0000       ' clear the pins

' Initialize the LCD (Hitachi HD44780 controller)
'
LCDinit:
                 x=0
                 DEBUG "Starting..."
                 PAUSE 500 ' Wait for LCD init
                 ' =================================
                 ' STANDARD HITACHI 44780 4-BIT INIT
                 ' =================================
                 char=%00000011 ' Set 8-bit mode (1)
                 GOSUB LCDcmd
                 PAUSE 10
                 char=%00000011 ' Set 8-bit mode (2)
                 GOSUB LCDcmd
                 PAUSE 10
                 char=%00000011 ' Set 8-bit mode (3)
                 GOSUB LCDcmd
                 PAUSE 10
                 char=%00000011
                 GOSUB LCDcmd   ' Set 8-Bit mode (4)
                 char=%00101000 ' Function Set 4-Bit mode
                 GOSUB LCDcmd
                 char=%0000100  ' Display Off
                 GOSUB LCDcmd
                 char=%0000001  ' Display Clear
                 GOSUB LCDcmd
                 char=%00000110 ' Entry Mode Set
                 GOSUB LCDcmd
                 char = clrLCD
                 GOSUB LCDcmd
                 char=%00001111 ' Display ON Cursor ON Blink ON
                 GOSUB LCDcmd
                 HIGH RS        ' Set RS Line High for character mode
                 char=%01000010 ' Write "A" to LCD
                 GOSUB LCDwr
                 char=%01000010 ' Write "A" to LCD
                 GOSUB LCDwr
                 char=%01000010 ' Write "A" to LCD
                 GOSUB LCDwr
                 STOP






' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
'
' Send command to the LCD
'
LCDcmd:          LOW RS ' enter command mode

'
' Write ASCII char to LCD
'
LCDwr:
                 DEBUG DEC x
                 OUTA = char.HIGHNIB ' output high nibble
                 PULSOUT E, 1        ' strobe the Enable line
                 OUTA = char.LOWNIB  ' output low nibble
                 PULSOUT E, 1
                 HIGH RS             ' return to character mode
                 RETURN



As you can see, I attempt to write "A" to the LCD three times, and in the process the cursor moves the the fourth position as if the three next to it are filled with characters, however no A's ever show up

I'm assuming its just some stupid mistake in my code since the company supposedly tests every LCD before they are shipped.

Thanks in advance for the help, any suggestions are appreciated.

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-17 00:58
    ndsbass -

    Check the contrast circuit for problems, if there is one. If not, you may need to add one. Check the datasheet.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming can't be all that difficult, it's nothing but 1's and 0's
  • ndsbassndsbass Posts: 7
    edited 2008-03-17 01:20
    Thanks for the reply. The contrast was my first thought after I started this thread. Currently the contrast pin is connected to ground, so I tried connecting it to the 5v supply and my cursor dissapeared. I'm assuming that if I can see the cursor, I should be able to see the characters? Is there any reason they wouldn't use the same contrast levels?

    edit - just installed a contrast pot, now my contrast is adjustable but still no characters [noparse]:([/noparse]

    On a side note, is there any possiblity the character ROM map was somehow erased? (yes I know what read only means, but is it a possibility?)

    Post Edited (ndsbass) : 3/17/2008 1:35:13 AM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-17 02:16
    ndsbass -

    Look at the small schematic on Page 2 of the datasheet. It shows that VR (a pot) needs to be placed between Vdd and Vss and the wiper lead connects to Vo (pin 3 on the LCD). Check that circuit out. That's where the problem probably lies.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming can't be all that difficult, it's nothing but 1's and 0's
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-17 02:30
    Sorry to barge in, but I see in your program listing that a PBASIC directive is missing.· It'll tokenize without it, but it's needed nonetheless -- to wit:
    · ' {$PBASIC 2.5}
  • ndsbassndsbass Posts: 7
    edited 2008-03-17 02:35
    Ya that is the contrast adjustment pin mentioned in my earlier post. I attached a pot as seen in the schematic but it had no effect. Now I can adjust my contrast but the the characters still don't show up. By having pin 3 (v0) connected straight to ground is the same as having the pot turned all the way to full contrast.

    Heres a picture of what I'm getting on my LCD. Excuse my cluttered breadboard
    main.php?g2_view=core.DownloadItem&g2_itemId=474&g2_serialNumber=2
    as you can see the three spaces before the cursor are where the characters should be, and I can move the cursor left and right by respectively removing and adding character commands, but the characters refuse to show up. I'm stumped on this one.

    Also just to clarify there is a cursor but it is set to blink at the display command in my code. My camera caught it on the blink which is why the entire matrix is filled. In between blinks I get an underscore, which I'm assuming is the default cursor?

    Post Edited (ndsbass) : 3/17/2008 2:44:23 AM GMT
  • ndsbassndsbass Posts: 7
    edited 2008-03-17 02:38
    PJ Allen said...
    Sorry to barge in, but I see in your program listing that a PBASIC directive is missing. It'll tokenize without it, but it's needed nonetheless -- to wit:
    ' {$PBASIC 2.5}

    Strange... When I insert it into my code the editor says symbol is already defined???
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-17 03:01
    Here's the Parallax source code for parallel LCDs (attached)
  • ndsbassndsbass Posts: 7
    edited 2008-03-17 14:15
    ya I saw that earlier but it seems my code is doing about the same thing. Still I'll give it another try when I get home from school today. I think I just need to change a few pins around since that uses pins 4-7 for 4bit operation and thus different rs and enable lines

    I'm just confused as to why my code isn't working. Since I can send commands in 4-bit mode it would seem the LCD has been initialized correctly? Why then shouldn't I be able to send characters in 4-bit? Anyways thanks for the help so far
  • ndsbassndsbass Posts: 7
    edited 2008-03-17 20:46
    We'll I found one problem, I had my data lines all switched around blush.gif. How the LCD was able to initialize like this, I have no idea. However, my code is still not working just yet and neither is the parallax code for hd44780's. I'm guessing I just need to follow my datasheet for the initialization procedure more closely, hopefully this will solve the problem.
  • ndsbassndsbass Posts: 7
    edited 2008-03-18 15:54
    its working! after fixing the data lines I tried out the original code I posted and now its working like a charm. Thanks to everyone for the help
Sign In or Register to comment.