LiquidCrystal and HD44780

Hi,
HD44780 based LCDs need some initialization writes that is not on LiquidCristal library.

For 8 bit:
write 0x30
wait 5ms
write 0x30
wait 100us
write 0x30
wait 100us

for 4 bit:
write 0x03 (one nibble)
wait 5ms
write 0x03 (one nibble)
wait 200us
write 0x03 (one nibble)

Actualy is the same writes, 0x30 three times.

ah, can this functionality be included on official LiquidCrystal library? I can write a patch.

The HD44780 datasheet says:

"If the power supply conditions for correctly operating the internal reset circuit are not met, initialization by instructions becomes necessary."

I think all my lcd modules doesn't use the reset circuit. I need to initialize it by software.
I modified the LiquidCrystal and put the code on:

http://code.google.com/p/arduinolcd/

I have a LCD with that chip and the original library works well.

I have a LCD with that chip and the original library works well.

I'm not saying that library does not work. I'm asking to add these software initialization codes. It will not affect the displays that work with current library and will work in displays that need this initialization.

Diego, I don't seem to be able to access that link but I have made a similar mod and it fixed a problem that I was having on an LCD panel.

I removed that project. Can I get your modification? Where?

I removed the init code from the constructor and added a begin method

void LiquidCrystal::begin()
{
//for 4 bit:
 delay(50);
 command(0x3);
 delay(5);
 command(0x3);
 delay(1);
 command(0x3);
 delay(1);

 
  command(0x28);  // function set: 4 bits, 1 line, 5x8 dots
  command(0x0C);  // display control: turn display on, cursor off, no blinking
  command(0x06);  // entry mode set: increment automatically, display shift, right shift
  clear();
}

I've been having the same problem with my LCD but I was waiting until I had my project a lot more developed before dealing with it. I made the changes to the library mem suggested and it now works perfectly.

I found this thread by searching, and I would second diego's request to have the change made to the original library. If I wasn't lucky enough to find the thread, I could have been struggling for a long time. My project is very harsh on the power supply, and I would have been adding decoupling caps all over the place figuring it was a brownout problem, especially since it was intermittent.

I'm using the seeedstudio 2x8 blue LCD.

Hi Mem, the liquidcrystal.cpp version you posted seems working with IDE 13 but not with IDE15.
Trying different modifications, I noted that command delay(x) cannot be used, only microseconds(1000*x) works.

I had the same problem using delay(x) in IDE12. I had to replace delay(5) with delayMicroseconds(5000) which is not an ideal solution due to interrupt considerations.

floresta

There are lots of LCD threads running (and not only on Arduino related forums) and it is hard to keep up with them. You may have missed Reliable LCD Operation - finally? in the software Interfacing section of this forum at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239570875.

I agree with diego on the need for what is called 'Initializing by Instruction' rather than relying on 'Initialization by Internal Reset Circuit' which is the technique the 'official' liquidCrystal library relies on. I have not yet looked over diego's code but I will do that as soon as I have a chance.

Meanwhile you might be interested in my solution. It is a replacement for the 'liquidCrystal.cpp' part of the official library that uses all the same routines so a sketch written for the official library should run with mine with no changes (except that I believe that it will work).

I have a limited number of LCD modules so my testing has likewise been limited. It would be nice to know if my version works for others where the official one does not. It would also be reassuring to find out that my version also works for those who have had no problems with the official version.

The link to my version along with my interpretation of the problem is: http://web.alfredstate.edu/weimandn/. This is a new website so it is kind of sparse at the moment.

floresta

floresta, I just did a quick test with your code and the good news is that it works on the two displays I tried. It also worked using the two calls to delay instead of delay Microseconds. When you tried it using delay, what were the symptoms? Do you have any idea why delay was not working for you?

mem:

When you tried it using delay, what were the symptoms?

To be honest I really don't remember what the symptoms were other than my message didn't appear! When I saw that someone else was having a similar problem I thought I'd wait and see what evolved.

Do you have any idea why delay was not working for you?

My guess is that it was still waiting - not returning from the delay routine.

the good news is that it works on the two displays I tried

Did the original version of liquidCrystal() work with those displays? In other words my changes didn't break anything but did they fix anything?

I added some explanatory material to the web page, any comments?

floresta

I have a limited number of LCD modules so my testing has likewise been limited. It would be nice to know if my version works for others where the official one does not. It would also be reassuring to find out that my version also works for those who have had no problems with the official version.

floresta - Thank you for addressing this issue, I was having the same problems when my sole power source was non-USB (i.e. +9VDC wall adapter). I have downloaded and tested your modifications with my HD4470-based XIAMEN GDM1602K and so far have not run into any problems.

Thanks again,
Blaker