Author Topic: WebbotLib: Parallel LCDs (HD44780) - need examples  (Read 3114 times)

0 Members and 1 Guest are viewing this topic.

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
WebbotLib: Parallel LCDs (HD44780) - need examples
« on: February 13, 2010, 01:31:52 PM »
Some of you requested I add this to WebbotLib - and I'm (trying to be) on the case.

Purchased 3 boards, all based on HD44780, of differing screen sizes.
Man - these devices are a swine to hook up as they are Molex/Pin Header City !!!


First thing I wanted to do was to get one working - any old how. ie if I know the display works, and my pin connections are valid then I can start testing my own code. Otherwise I don't know if its my code, my wiring or my hardware!

As a first basic attempt - I thought hook up Gnd and +5v (to pins 1 and 2) and switch on. Nothing. Then I thought: ok so pin 3 on most of them allow you to add a pot for contrast control. Cant be bothered with a pot so lets connect that to +5v as well. Still nothing.

Hmm. So contrast isn't the backlight - obviously. But I thought my display would show something even if it was a splash screen. Tried all 3 displays but - nothing. Not a flicker.

Spent hours crimping lots of wires as this sucker needs a lot of them. Hands hurt!

Next step - thought I'd go back to the lcd support in AVRlib which claims to support it. This reminded me why I wrote WebbotLib in the first place. Got all sorts of compile errors when trying to use the Axon. Too frazzled to care and try to fix.

So here is my question.

Can anyone (especially you guys that wanted it added) provide me with a compiled HEX file for the Axon or Axon II that just shows a 'Hello World' msg on the screen which you MUST have tested to make sure works! 

I just need to make sure my wiring etc is correct, and my hardware works, before I can even start on my own code.

Please let me know what ports you've used on the Axon - and what they are connect to on the display - from which I can tell if you are using 4bit or 8bit mode. (NB - I'm not interested in memory mapped usage for now - ie mapping the display into the RAM address space - as thats a lot more advanced).

Until I can get a display to do something then I'm in limbo!!

Mental note for newbies - these things are a major pain - if you've got the bucks then just buy a serial/UART one. Had those running in about 2 minutes!

Unlessl I hear from interested parties then I'll have to put this on hold - too many other WebbotLib things I can get on with. So please please get back.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Pratheek

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 125
  • Helpful? 3
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #1 on: February 13, 2010, 08:34:29 PM »
Connecting Pin 3 of the LCD to +5V will keep the brightness to minimum. Try connecting it to Gnd, will increase the brightness to maximum.

To check if your power connections are correct, connect Pin 1 and 2 to Gnd and Vcc as you have already done and connect Pin 3 to Gnd, if you see black boxes displayed on the LCD you can be sure the wiring is correct.


Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #2 on: February 13, 2010, 10:22:43 PM »
Thanks Pratheek. Why didn't that occur to me !

Now - anyone going to volunteer some  working code.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #3 on: February 13, 2010, 10:32:49 PM »
Quote
Mental note for newbies - these things are a major pain - if you've got the bucks then just buy a serial/UART one. Had those running in about 2 minutes!
Told ya so :P

Quote
Connecting Pin 3 of the LCD to +5V will keep the brightness to minimum. Try connecting it to Gnd, will increase the brightness to maximum.
Sounds like something useful to control with a digital I/O for power saving mode . . .

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #4 on: February 13, 2010, 10:41:59 PM »
Quote
Mental note for newbies - these things are a major pain - if you've got the bucks then just buy a serial/UART one. Had those running in about 2 minutes!
Told ya so
Yep - been using them for years. Always been happy with them. Only diffs are different make/models use different stuff for things like ClearScreen/Home/GotoXY etc. Next version of WebbotLib supports all that.


Quote
Connecting Pin 3 of the LCD to +5V will keep the brightness to minimum. Try connecting it to Gnd, will increase the brightness to maximum.
Sounds like something useful to control with a digital I/O for power saving mode . . .
Maybe. Although this is 'contrast' not brightness and I'm unsure as to whether it needs more power or not. DMM time ! Normally you use a pot so you can trim the contrast. Of course you could use PWM with an RC filter and make it variable in software. But for now - if I can connect it to Gnd and save another pin then great.
The big candidate for power saving is use of any backlight - that typically requires between 10x and 100x the power required to make the lcd work.
So WebbotLib lets you turn it on or off.

« Last Edit: February 13, 2010, 10:44:44 PM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Pratheek

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 125
  • Helpful? 3
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #5 on: February 13, 2010, 11:06:09 PM »
If saving pins is what you want to do I have a suggestion - go for 4 bit mode and leave the RW pin unconnected(coding becomes a little tougher though).

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #6 on: February 13, 2010, 11:09:28 PM »
Was gonna allow for 4 bit and 8 bit modes.

your contrast hint was a great help. So what do you do in practice? Connect to 0v, +5v or add an external pot (ie more hardware!).

But for now - as per original - post: I'm looking for a compiled HEX file just so I can test LCD is working ok.

Then I can create my own code.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Pratheek

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 125
  • Helpful? 3
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #7 on: February 13, 2010, 11:15:08 PM »
Connecting Pin 3 of the LCD to Gnd will work.
I usually add a pot because it gives you finer control over the LCD visibility. 

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #8 on: February 14, 2010, 05:42:22 PM »
Spent hours crimping lots of wires as this sucker needs a lot of them. Hands hurt!

Mental note for newbies - these things are a major pain - if you've got the bucks then just buy a serial/UART one. Had those running in about 2 minutes!
Told ya so :P

No offense guys, but BUCK UP! I think you are going against the spirit of SoR and all hobbyists. If a little extra work is such a pain, why bother building a $50 robot when you can buy a Rovio for $200? This site is about buying the parts for cheap and putting it together for yourself, not buying a turn-key product and just plugging it in.

 I can laugh at Webbot for taking 'hours' interfacing LCD's when it just took me 5 minutes to wire one to an Arduino, but he could equally laugh at me for taking hours programming something he could do in minutes. But we shouldn't be scarring off 'newbies' just because it took more time for us to do something outside our field of expertise.

/rant

Anyway, Yes, To use a el-cheapo parallel lcd, you need a few extra resistors to connect the backlight to the battery, and a pot to adjust contrast. All the LCD's i bought came with a pretty clear wiring diagram.

I never codded a driver for one on the Axon, I always used them on Arduino's which have a driver built into their IDE.
« Last Edit: February 14, 2010, 05:44:17 PM by madsci1016 »

Offline richiereynolds

  • Full Member
  • ***
  • Posts: 112
  • Helpful? 3
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #9 on: February 14, 2010, 06:13:15 PM »
I used Peter Fleury's library for this with an atmega328p - http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html
It worked pretty much straight off and he's got a test driver program along with the small lib. He's got 8 and 4 bit modes covered and you can define pins and different lcd sizes in the header..

Compiled with GCC in AVR studio.

I did have to connect the RW pin though, tried a few libs that said just to ground it but none of them worked and it didn't work with Peter's library either, though he never claimed it would.
The wiring is shown on his site.

I put a 1K pot with the across gnd and 5V with the wiper on pin 3 for contrast.
The lcd I have also had an led backlight so I had +5 and gnd on pins 15 and 16.

I can post some actual code if you like but it's really just Peter's lib so probably no point.

Offline billhowl

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 32
  • Your success is in your hands.
« Last Edit: February 14, 2010, 06:53:26 PM by billhowl »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #11 on: February 14, 2010, 06:26:43 PM »
Hi,

When the LCD is connected right and powered up, it should show all positions as black boxes until initialized.
That should at least tell you when the hardware is as needed.

The pot might be a good idea, at least initially, as it is very different from one display to the next, what the actual contrast voltage should be - some even needs a negative contrast voltage.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #12 on: February 14, 2010, 10:13:13 PM »
Quote
No offense guys, but BUCK UP! I think you are going against the spirit of SoR and all hobbyists. If a little extra work is such a pain, why bother building a $50 robot when you can buy a Rovio for $200? This site is about buying the parts for cheap and putting it together for yourself, not buying a turn-key product and just plugging it in.
Definitely my personal preference, but I like to buy all my components off-the-shelf. My goal is to build a neat robot, and so I'll use the best/easiest components. I really have no interest in making my own sensors, motor drivers, microcontrollers, etc. Only when the off-the-shelf components suck am I forced to design my own (aka the Axon :P). There are so many things that can go wrong with a robot, so keeping things simple throughout will make it much more reliable. The parallel LCD wiring is a distraction to my goal, and I'd happily pay an extra $15 to avoid the potential hours in debugging. :P

Offline GearMotion

  • Supreme Robot
  • *****
  • Posts: 489
  • Helpful? 24
  • Two decades+ of Embedded Design
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #13 on: February 15, 2010, 09:03:42 AM »
I really like LCDs and the HD44780 (and compatible) are great to use. The only off-putting part is just as you have discovered. If you do everything right - get all of the steps done correctly - then they will display something. But if something is wrong - one little thing - they display NOTHING.  

The very first time I used a character LCD was in the 80s. My trouble was that I was sending it commands too fast. But I didn't know if it was that, or if it was that I wasn't sending the RIGHT commands, or in the RIGHT ORDER, etc.

So I pulled it out of circuit and wired it to a set of 11 DIP switches. I manually initialized it and wrote a character to the display after the initialization sequence. Then I knew I had at least that much correct.

I'd offer you a HEX file if I had one, but I don't. I would advise writing out an initialization sequence SLOWLY to test. Set your data lines and control lines and toggle the enable line to send the command.

Send out this sequence of initialization commands:

0x33
0x33
0x38
0x0C
0x01

And then write a visible character such as 'H'.


Edit: Start your testing in 8-bit mode and when things work move to 4 bit mode. Sequence above is for 8 bit. Also start with the read/write line fixed to 'write'. Again, send commands slow (delays between commands longer than the spec sheet) to start and the LCD display will have a chance to process the commands. Work your way toward using 'read' to query the ready bit.

« Last Edit: February 15, 2010, 09:10:34 AM by GearMotion »

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #14 on: February 15, 2010, 01:48:48 PM »
I have a 'Hello World' in 4 bit mode. Yahoo! The simplest of things - but I'm happy

Will carry on testing - but cant test 4 line mode as I haven't got one. Out of all my favorite (UK) sites then only one did parallel displays - and no 4 lines ones. But thats another story.

Next main thing is trying to thrash out the following - so as to get uniform behavior between ALL parallel and serial displays:-
1. Auto line wrap on/off - ie move to next line once at right hand side
2. Auto scroll mode on/off - useful for logging etc. ie once you go beyond the end of the last line then scroll up, clear the bottom line, start printing at bottom line. Not seen any HD44780 cmds, examples, to do this. Guest it will mean reading each char from one line and writing it to the line above and then zapping last line.
3. Cursor on/off/blink etc
4. Custom characters. May reserve the first few for drawing vertical/horiz bar graphs and add that to the lib - ie have bar graphs to show as many ADC inputs as you have space for.

So 'madsci' is probably now laughing his socks off!! Blast him!! Still wish I had a Molex crimper - thats where the time goes. Along with 'get out all my kit out onto the kitchen table', 'spend 10 minutes', 'put it all away as we need to eat' etc etc

But the above points help demo some of the complexities of writing WebbotLib drivers. Its not just a question of creating something that works - but its adding the cross-compatibility between different devices. This is where the 'end user power' comes in - and so its worth it. Even if some displays don't support all the features.

Thanks to all for their comments. Only two 'unknowns' left:
1. One of my displays has a whole load of solder tags in a straight/single line but the silk screen has no pin numbers on. So I dont know if pin 1 is on the left or on the right. Waiting for supplier to advise.
2. None of my parallel screens have a backlight. This may not be an issue as it looks like they aren't really supported by the HD44780. You just give it power / or maybe use PWM if you want a dimmer. 


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #15 on: February 15, 2010, 02:51:09 PM »
Lol, Nah, i have too much respect for you to laugh THAT hard.  ;D

For the 4 line, Feel free to shoot me hex's for Axon 2 and i will video tape the result and send it back to you.

Also, to save your hands, I use pre-crimped wires and snap-on connectors. I keep an assortment in the parts bin and pull out what i need to make a connection. So for example, if your playing with some screens, just solder on a pin header and make a few cables.

http://www.pololu.com/catalog/category/71

If you are going to be 'reading' from the bus, this means another I/O is used and we can't just tie R/W to low. If you are worried about too many IO lines used, could you not just buffer the characters locally and just shift lines down and 'refresh' the whole screen?

For examples, have you read through the Arduino LCD driver? It might provide some insight. To save the work, I zipped it up for you.

http://www.billporter.info/wp-content/uploads//2010/02/LiquidCrystal.zip

and here is a description of the functions:

http://arduino.cc/en/Reference/LiquidCrystal?from=Tutorial.LCDLibrary

Hope this gives some help.



Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,152
  • Helpful? 110
Re: WebbotLib: Parallel LCDs (HD44780) - need examples
« Reply #16 on: February 17, 2010, 11:19:29 PM »
Hopefully now all 'released' in Version 1.15 http://webbot.org.uk/iPoint/35.page
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here