Stumped with LCD setup
Ugha
Posts: 543
Hi all.
I'm rather embarassed to admit that I'm in waaaay over my head on this one.
I've tried for the past two days to get a LCD to display... anything.
I'm pretty sure it works fine and everything's ok... I think I even wired it up
right. My problem is I have no freaking clue how to use it.
I'm attempting to get what I think is a parallel LCD to display pretty much
anything using a BS2.
I had problems finding a datasheet for the LCD (which, according to the
site I got it from is MTC-S16204A).
The only datasheet I could find was for a MTC-S16204XFYHSAY... but as
far as I can tell, they are pretty much identical.
This is the URL for the datasheet which I THOUGHT was quite clear and simple.
Guess my ignorance bit me in the butt.
http://www.microtipsusa.com/product_pdfs/Character/16x2/16204/MTC-S16204XFYHSAY.pdf
I got most of my info from this site:
http://www.weethet.nl/english/basicstamp2_lcdcontrol.php
I knew it was for a different LCD design, but the pinout was pretty close
so I used it as a basis then changed the instructions.
The site mentions initializing the display, but I couldn't find any info in
the datasheet about a proper order, so I just used what "makes sense"
to me. This is most likely my problem.
I'm also using the wiring thats displayed on the site with one exception,
I'm running pin 3 to +5v instead of Gnd.
Below is some test code I was using to attempt displaying the number 3.
' {$STAMP BS2}
' {$PBASIC 2.5}
char VAR Byte
DB4 PIN 0
DB5 PIN 1
DB6 PIN 2
DB7 PIN 3
RS· PIN 4
ENABLE PIN 5
clear_display CON %00000001
return_home CON·· %00000010
display_off CON·· %00001000
display_on· CON·· %00001100
enable4bit· CON·· %00100000
enable8bit· CON·· %00110000
cursorblink CON·· %00001111
DIRL = %00111111
OUTS = $0000
PAUSE 500
char = enable4bit
GOSUB LCDcmd
char = display_on
GOSUB LCDcmd
char = return_home
GOSUB LCDcmd
char = clear_display
GOSUB LCDcmd
char = cursorblink
GOSUB LCDcmd
Start:
char = %00110011
GOSUB LCDwr
PAUSE·1000
char = clear_display
GOSUB LCDcmd
GOTO Start
END
LCDcmd:
········ ······· LOW RS
LCDwr:
················ OUTA = char.HIGHNIB
················ PULSOUT ENABLE, 1
················ OUTA = char.LOWNIB
················ PULSOUT ENABLE, 1
················ HIGH RS
················ RETURN
I know teaching a newbie how to use a LCD display will be a really
daunting task, so I don't expect anyone to take the time to do it.
I'm putting this project on the back burner til I figure it out or get
some help.
Thanks for taking the time to read this [noparse]:)[/noparse]
I'm rather embarassed to admit that I'm in waaaay over my head on this one.
I've tried for the past two days to get a LCD to display... anything.
I'm pretty sure it works fine and everything's ok... I think I even wired it up
right. My problem is I have no freaking clue how to use it.
I'm attempting to get what I think is a parallel LCD to display pretty much
anything using a BS2.
I had problems finding a datasheet for the LCD (which, according to the
site I got it from is MTC-S16204A).
The only datasheet I could find was for a MTC-S16204XFYHSAY... but as
far as I can tell, they are pretty much identical.
This is the URL for the datasheet which I THOUGHT was quite clear and simple.
Guess my ignorance bit me in the butt.
http://www.microtipsusa.com/product_pdfs/Character/16x2/16204/MTC-S16204XFYHSAY.pdf
I got most of my info from this site:
http://www.weethet.nl/english/basicstamp2_lcdcontrol.php
I knew it was for a different LCD design, but the pinout was pretty close
so I used it as a basis then changed the instructions.
The site mentions initializing the display, but I couldn't find any info in
the datasheet about a proper order, so I just used what "makes sense"
to me. This is most likely my problem.
I'm also using the wiring thats displayed on the site with one exception,
I'm running pin 3 to +5v instead of Gnd.
Below is some test code I was using to attempt displaying the number 3.
' {$STAMP BS2}
' {$PBASIC 2.5}
char VAR Byte
DB4 PIN 0
DB5 PIN 1
DB6 PIN 2
DB7 PIN 3
RS· PIN 4
ENABLE PIN 5
clear_display CON %00000001
return_home CON·· %00000010
display_off CON·· %00001000
display_on· CON·· %00001100
enable4bit· CON·· %00100000
enable8bit· CON·· %00110000
cursorblink CON·· %00001111
DIRL = %00111111
OUTS = $0000
PAUSE 500
char = enable4bit
GOSUB LCDcmd
char = display_on
GOSUB LCDcmd
char = return_home
GOSUB LCDcmd
char = clear_display
GOSUB LCDcmd
char = cursorblink
GOSUB LCDcmd
Start:
char = %00110011
GOSUB LCDwr
PAUSE·1000
char = clear_display
GOSUB LCDcmd
GOTO Start
END
LCDcmd:
········ ······· LOW RS
LCDwr:
················ OUTA = char.HIGHNIB
················ PULSOUT ENABLE, 1
················ OUTA = char.LOWNIB
················ PULSOUT ENABLE, 1
················ HIGH RS
················ RETURN
I know teaching a newbie how to use a LCD display will be a really
daunting task, so I don't expect anyone to take the time to do it.
I'm putting this project on the back burner til I figure it out or get
some help.
Thanks for taking the time to read this [noparse]:)[/noparse]
Comments
www.parallax.com/Store/Accessories/Displays/tabid/159/CategoryID/34/List/0/Level/a/ProductID/49/Default.aspx?SortField=ProductName%2cProductName
Asking Question is half the knowledge. And I add, "make it a nibble size.....grin
Having said that, be mindful. I am very NEW (4 days exposed) to the art and tricks of SB2. Like you, I want to learn. Hence, lets stream line learning process.
Map out your technology handicaps to help with your learning curve. Like, to understand the latch, you must know gates etc. Learn to crawl-->walk--> like some fine people on this forum. I have not gone to the URLs that you have provided, but here is my research for you. Don't quit. Preparing for Olympics is tough!!!!!!
This thing looks easy...grin. Don't mean to sound like grandpa here.
I think it will be wise to get products with support when you are that new. I am buying all my nuts and bolts from Parallax.
http://www.parallax.com/dl/docs/prod/audiovis/SICSerialLcd.pdf
Please let me know how it works out.
NewStamper
NewStanmper:
While I love the Parallax products, there's a big difference between Parallax's $29.95 and the $3.95 I payed for my LCD.
And thanks to you too for the PDF link.
NewStanmper: Unfortunately that's for a serial LCD (much simpler interface as I have recently found out)... mine's parallel.
I'll keep fiddling with it, maybe I'll have some luck down the road.
Any other suggestions are VERY much appreciated.
Greetings,
I know it was serial. I did not know what you had. Here is your problem. You do not have documentation. Your LCD could have all sand inside that may need backing to turn it into some type of logical IC for it to work.
I ask you to read my earlier comments again, may be twice. Then read Mike's once more. Then frame both...... grin
You are lacking arranging the P's and Q's and project management here.... grin
I think in the long run, with time sacrificed, you will be a learned guru. I am right behind you.
I would put aside your LCD for now and buy one that has the HD44780 controller - you can find them for around $8
If you use 4 bit mode on the HD44780 display, you'll 6 or 7 pins to connect the LCD to your Basic Stamp. You can reduce this to 1 pin if you use a serial LCD. You can buy a serial LCD kit that contains a 'serial backpack', board and about 10 components that need to be soldered to the board for $15 (google K107 kit) plus the cost of the LCD. Or you can buy Parallax's fully assembled and tested serial LCD for $7 more. The Parallax serial LCD is a very good deal at $29.95.
I can't seem to attach any file over half a MB, so I can't put the datasheet for the KS0066 here, but I
have it and I'm willing to email it to anyone who wants to take a look and maybe give me a hand figuring
this out. PM me with your address and I'll send it within a day.
And I picked a parallel LCD instead of a serial one because I wanted to get down to the basics and really
understand how LCDs work. I have no specific project I want to put it in, I just want to learn.
On the other hand, I have to second the opinion that using a serial LCD is the way to go. It just isn't worth the time and trouble not to. I agree with Forrest and highly recommend the ones from Peter Anderson, it's available separately (without an LCD, kit or built) from Wulfden.org. The ones that Parallax sell are also good and very easy to use. My only issue with them is that the module isn't available separately (hint hint) because I personally don't like LCDs with that sickly green backlight color.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
The first thing to try is:
0. Make sure you've got it wired correctly. I once had an LCD where pin 1 was on the side where I didn't expect it to be. Most of the LCDs I've got have it labeled on the copper side of the board.
Let me know how that works out.
Mike
Brain check: Deleted steps 1-3. From looking at the Parallax example and some code I dug up: you tie R/W low, and pulse the Enable pin. Sorry for any confusion this might have caused.
Post Edited (MikeK) : 2/24/2008 3:11:32 PM GMT
Your post not only helped me correct the mistakes in my code and wiring, it made me realize something.
You mentioned checking the wiring so I went back and looked at the schematic to see for sure which side
was pin one... and I realized something that's totally screwed up.
You'd expect pin1 to be on the left side... or maybe the right. Nope... the schematic has the pin layout
like this:
[noparse][[/noparse]14][noparse][[/noparse]13][noparse][[/noparse]12][noparse][[/noparse]11][noparse][[/noparse]10][noparse][[/noparse] 9][noparse][[/noparse] 8][noparse][[/noparse] 7][noparse][[/noparse] 6][noparse][[/noparse] 5][noparse][[/noparse] 4][noparse][[/noparse] 3][noparse][[/noparse] 2][noparse][[/noparse] 1][noparse][[/noparse]15][noparse][[/noparse]16]
Pin1 is third from the end!
I've never seen anything like this before... although I haven't worked with LCDs before so this may
be the norm.
Anyways... I rearranged the wiring to properly account for the location of pin1 and to go along with
your suggestions and I made a tiny bit of progress.
The LCD's backlight stays on. So far I got a really expensive nightlight [noparse]:)[/noparse]
I'm thinking that my problems are in my code...
You said that the KS0066 is HD44780 compatible MikeK? Does that mean it would have the same
initalization requirements as the HD44780? As per the website below (I googled HD44780 and initalization).
http://www.geocities.com/dinceraydin/lcd/initalization.htm
If so, why on earth don't they put stuff like this in the datasheet?
I'll be tinkering with the LCD again later and I'll keep you guys updated with what happens. If everything
works out, I may end up putting up a website with a walkthrough on how to use this danged thing simply
so other people won't have as much trouble.
The most common problem I've seen when connecting an LCD is to make sure the contrast pin is connected properly thru a potentiometer. If this isn't right then you'll see nothing on the LCD.
The circuit and code I listed above for the Parallax Parallel LCD should work with your LCD.
It says pin 3 is Vo... Power Supply For LCD Panel
Most everything I've seen on the net from most all LCDs with backlights have pin 3 as contrast... what the heck?
If pin 3 IS the contrast pin, can't I just tie it to ground? Or do I HAVE to use a pot? How big of pot should I use?
Also... I can't control the backlight. It's tied via hardware to +5v with a resistor on the back (see the section of
the datasheet called Jumper Explanation). I checked on this and it is, indeed tied to +5v and Ground.
So whenever the LCD is on, the backlight will be on.
20K pot. I've successfully used 5K and 10K pots also, although they draw more current (1ma for 5K). The control is coarser the higher the value of the pot.
Basically, +5v to one end of the pot, 0v to the other end, and connect the wiper to Vo (pin 3).
Using a pot and redoing the wiring... I've managed to make some squares show up!
Ok, minor victory, but still... it's a victory for me.
Question though... one corner of the squares starts fading in a second or two then
it creeps forwards until almost all the squares are gone.
I got a feeling this may mean that I'm either putting too much, or too little power somewhere.
Any suggestions?
I ran an exact copy of Parallax's parallel LCD code for 30 seconds, no sign of anything getting hot.
Thank you again for your help and suggestions... any other ideas? [noparse]:)[/noparse]
Edit:
The squares are on the right side of the LCD, there are 8 of them arranged like this:
####
####
They fade from the bottom left at an angle until they are almost completely gone.
·