Shop OBEX P1 Docs P2 Docs Learn Events
Stumped with LCD setup — Parallax Forums

Stumped with LCD setup

UghaUgha Posts: 543
edited 2008-02-25 04:04 in BASIC Stamp
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]

Comments

  • ForrestForrest Posts: 1,341
    edited 2008-02-21 04:02
  • NewStamperNewStamper Posts: 33
    edited 2008-02-21 04:11
    Ugha:
    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
  • UghaUgha Posts: 543
    edited 2008-02-21 05:13
    Forrest: Thanks for the URL, I'll check it out and see if it works with my LCD.

    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-21 06:41
    Yes, there is a big difference between $30 for something that's well tested and well supported and $4 for something that may work and may take a lot of experimenting and research. That's the gamble you take. You win sometimes and you lose sometimes. If you've got the time and the interest, it's a useful gamble. Even if it doesn't work, you've learned something. On the other hand, if you really want to accomplish something else and the display is just a means to an end, buying the Parallax product is worth the support behind it.
  • UghaUgha Posts: 543
    edited 2008-02-22 02:17
    Forrest: I checked out that info, so far no luck but I'll keep tinkering with it.

    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.
  • NewStamperNewStamper Posts: 33
    edited 2008-02-22 06:13
    Ugha:
    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.
  • ForrestForrest Posts: 1,341
    edited 2008-02-22 11:55
    I found your LCD on the Electronic Goldmine website and it doesn't look like it uses the standard HD44780 LCD controller that's common in the industry and is used on the Parallax Parallel LCD.

    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.
  • UghaUgha Posts: 543
    edited 2008-02-23 02:42
    No... it uses a KS0066 or compatible.

    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.
  • RDL2004RDL2004 Posts: 2,554
    edited 2008-02-23 12:29
    The KS0066 is supposed to be HD44780 compatible. The HD44780 is as close to an industry standard as you are likely to find these days and it would be unusual to find a character LCD controller that wasn't compatible. I would check and double check your wiring and everything else you can think of, your particular module may have "quirks".

    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
  • MikeKMikeK Posts: 118
    edited 2008-02-23 22:37
    I got the datasheet from Ugha. As far as I can tell, it is an HD44780 compatible LCD.

    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
  • UghaUgha Posts: 543
    edited 2008-02-24 12:36
    Thanks for the help MikeK [noparse]:)[/noparse]

    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.
  • ForrestForrest Posts: 1,341
    edited 2008-02-24 14:35
    Pin 15 and 16 power the backlight - you shouldn't need to connect those for debugging purposes and this keeps the overall power requirements for the LCD very low (around 1 mA). The backlight typically needs about 100 mA and you'll kill a 9V battery is no time with the backlight on.

    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.
  • MikeKMikeK Posts: 118
    edited 2008-02-24 15:14
    What Forrest says is true. It's a Catch-22 though. If there's nothing on the screen, the contrast adjustment won't help you. If there's something on the screen and the contrast isn't set right, you won't see it anyway. smile.gif
  • UghaUgha Posts: 543
    edited 2008-02-24 18:05
    The datasheet doesn't actually say there IS a contrast pin.

    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.
  • MikeKMikeK Posts: 118
    edited 2008-02-24 19:12
    Page 11 of http://www.microtipsusa.com/product_pdfs/Character/16x2/16204/MTC-S16204XFYHSAY.pdf shows their suggested circuit, using a
    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).
  • UghaUgha Posts: 543
    edited 2008-02-25 02:49
    Progress!

    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?
  • MikeKMikeK Posts: 118
    edited 2008-02-25 03:57
    If you had to solder wires or a connector to the LCD, make sure you didn't short any of the pins together. Check the wiring. CAREFULLY, see if any of the chips on the LCD board, or the contrast pot, are getting hot.
  • UghaUgha Posts: 543
    edited 2008-02-25 04:04
    I've still got it in the BOE's breadboard... that's why I picked this LCD, very long pins meant for breadboarding.

    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.
    ·
Sign In or Register to comment.