16x2 LCD woes - solved
vampyre
Posts: 146
Hi all, i'm hoping someone has seen this problem before.
I have a 16x2 hitachi driver based LCD with a nifty white backlight. I had it up and running fine with the basic stamp 2, then i tried hook it up to my prop using the LCD 4bit driver in the object exchange.
at first it didn't work. then i realised i had my RS and E pins backwards. so i changed that. instead of hooking up to pins 0-4 i used 20-23, which i figured wouldn't work right off the bat. i changed the constant pin assignments, and moved the shift commands around. it now seems to kind of sort of work. it appears only the first line is working and the text is garbled ,but not completely.
for instance "hello world" comes out _ello`$w<-dxb.
do u guys think my LCD is fried, or is this more likely a software problem?
Post Edited (vampyre) : 5/27/2008 4:14:22 PM GMT
I have a 16x2 hitachi driver based LCD with a nifty white backlight. I had it up and running fine with the basic stamp 2, then i tried hook it up to my prop using the LCD 4bit driver in the object exchange.
at first it didn't work. then i realised i had my RS and E pins backwards. so i changed that. instead of hooking up to pins 0-4 i used 20-23, which i figured wouldn't work right off the bat. i changed the constant pin assignments, and moved the shift commands around. it now seems to kind of sort of work. it appears only the first line is working and the text is garbled ,but not completely.
for instance "hello world" comes out _ello`$w<-dxb.
do u guys think my LCD is fried, or is this more likely a software problem?
Post Edited (vampyre) : 5/27/2008 4:14:22 PM GMT
Comments
Read this please. Maybe you have the same problem as me, but now is working.
http://forums.parallax.com/showthread.php?p=724362
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
You need to send an extra nybble after setting 4-bit mode or else it is likely to get confused about byte timing.
I found it *always* worked after a hard-reset, but then any subsequent reset (like reset the prop but don't power down the display) would cause garbled data or an improper reset.
See below for my revised INIT routine (which has been heavily tested over 100 cycled prop resets now)
@BTX: I had read your post when trying to figure out what was wrong with my LCD. I'm reletivly sure that my RS,RW and E pins are
correct now. in your post you say that the LCD bus MUST be on pins 0,1,2 and 3 .... why is that? Those pins are already used in my
design, so i have mine hooked up to 20-23... do you think this could be the problem?
@BradC: Your post was enlightening. I tried looking at the code i have and modifying it to match yours but my results were semi-successfull.
what is BL in your code? i couldn't find that variable in the object. I noticed that in your code you strobe the E line after setting the 4bit mode
, when i do that in my code i get two lines of text instead of just the one... but now all the charachters are garbled instead of just some of them.
also i've found that the LCD doesn't seem to boot at all from a cold boot, it only seems to work when the prop is programed or reset with the reset button
I mean that the doccumented is bad write, and can confuse and wont work.
If you want to use anothers pins is fine, just follow the correct "order" for the pins in the code, and rename the "P0, P1, P2, P3" for your needs.
This is the code that I download and works fine with corrected "comments".
I've the same problem and was the msb-lsb in the four bits data inverted, look that carrefully.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Whoops.. you can remove the calls for BL. they switch my backlight on.
If you are now getting 2 lines and everything is garbled it sounds like you may have your data lines backwards..
For reference, here are mine.
I've hardwired the R/W pin to GND as I don't intend to read from the display any time soon.
In fact, I'll just attach the object..
BradC, your modified object fixed everything. I really appreciate all your help. Perhaps you should consider uploading your modified version of the object to the object exchange?
Thanks alot for all your help.
-James