11
\$\begingroup\$

I'm using an HD44780 clone LCD module a KS0066U. Everything works ok on the module except when I rapidly power cycle the device (on->off->on). For some reason a very short interruption in the power causes the display module to improperly initialize as a 1-line LCD instead of a 2-line LCD display. What would cause this behavior? Is there any way to prevent it in software?

EDIT: I'm using the display controller in 4-bit mode not 8-bit mode.

\$\endgroup\$
3
  • \$\begingroup\$ It seems no-one thought your question worth up-voting, quite odd. \$\endgroup\$
    – Kortuk
    Commented Oct 22, 2010 at 20:39
  • \$\begingroup\$ The datasheets for some of the HD44780 clones are pretty poorly written. My goal was to get a conversation going on what the proper way to initialize them was. Maybe I'm the only one who's had problems using them in 4-bit mode. \$\endgroup\$
    – mjh2007
    Commented Oct 22, 2010 at 20:42
  • \$\begingroup\$ Nope, I'm going through the same trouble right now running in 4-bit mode. It's been about 15 years since I last programmed a simple character LCD, and I remember it being a real pain to debug back when I was in school. I'm not as far as you, though -- I can't even get the initialization right because I can't display a single character, yet. :) \$\endgroup\$
    – Dave
    Commented Apr 7, 2011 at 13:30

5 Answers 5

4
\$\begingroup\$

I changed my initialization code so that it sent the upper 4-bit nibble of the function set command twice. Following which I resent the upper 4-bit nibble followed by the lower 4-bit nibble. This does not match the datasheet which seems to indicate that you can send the upper 4-bit nibble then send the function set command upper 4-bit followed by lower 4-bit.

// Works sometimes pseudo-code
port=0x20;
e=1; e=0;
port=0x20;
e=1; e=0;
port=0xC0;
e=1; e=0;

// Works all the time pseudo-code
port=0x20;
e=1; e=0;
e=1; e=0;
port=0x20;
e=1; e=0;
port=0xC0;
e=1; e=0;

\$\endgroup\$
2
\$\begingroup\$

My guess would be that you are missing a necessary delay in your initialization sequence. If the display is busy when you try to send a command, that command will be ignored. If when you start your procedure, the display is in four bit mode and has just had "0000" clocked in as the first half of a command, then when you clock in "0011" the display will see the whole command as "00000011", which will cause the display to be busy for up to 1.6ms.

Incidentally, it is good if possible to wire the low-order data wires from the display in such a way that when a "0011" command is sent to the display, the whole 8 bits seen by the display will form a mode-set command which is correct for the type of display you are using. That will help avoid any display glitches when resetting a display which is already in use (periodically resetting the display is a good idea, if it can be done glitchlessly, since it will ensure that if the display somehow gets into a bad mode it will fix itself).

\$\endgroup\$
1
\$\begingroup\$

I found a workaround for the problem:

I added a 1000milisecond delay at startup, before initializing/configuring the LCD controller. It worked pretty good for me.

A lower delay(100, 200ms) not worked so well. Just a note: It happened only in 4bits databuss.

Good luck!

\$\endgroup\$
0
\$\begingroup\$

Inserting a delay in your code so when it switches on it gives the LCD long enough to initialize when it starts up. A maximum of a few hundred milliseconds.

You could also try connecting the LCD power to the microcontroller and powering off the LCD for a second after start up.

\$\endgroup\$
5
  • \$\begingroup\$ Already have 100 ms delay on start-up \$\endgroup\$
    – mjh2007
    Commented Oct 20, 2010 at 21:41
  • \$\begingroup\$ Try my other suggestion then. You could even control the LCD power from a pin directly; it shouldn't draw more than a few mA. \$\endgroup\$
    – Thomas O
    Commented Oct 20, 2010 at 21:51
  • \$\begingroup\$ is there really a maximum allowable delay? I thought the main thing with these LCDs is that you wait the minimum amount, but if you can't get the timing correct, you can play it safe and just wait longer. \$\endgroup\$
    – Dave
    Commented Apr 7, 2011 at 13:39
  • \$\begingroup\$ @Dave, you may have misinterpreted "maximum delay", it's just a sensible delay I'd recommend. For example, waiting a few hours would be a bit extreme... \$\endgroup\$
    – Thomas O
    Commented Apr 7, 2011 at 20:04
  • \$\begingroup\$ LOL! Well I figured that's what you meant, but I wanted to ensure that I wasn't missing something, as I have yet to get my LCD initialized. I wonder if I should go and grab a pot to make sure it's not the contrast that's screwing me up here. :) \$\endgroup\$
    – Dave
    Commented Apr 7, 2011 at 20:10
0
\$\begingroup\$

Not sure if this helps AT ALL, but I messed with the KS0066U on an Arduino project. Here is the link.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.