HD44780 Custom glyphs get corrupted when power lost?

Basically I want the device to have a "boot screen" with a loading bar at the bottom that scrolls across the screen. It works perfectly when I upload it or reset it without unplugging the arduino. but as soon as the arduino looses power, the glyphs get corrupted. However, they somehow get "uncorrupted" if i reset the arduino. you can see what i mean in this video: http://www.youtube.com/watch?v=s8sur_Da7IY sorry about horrible audio/video. i was using my cheapo smartphone camera.

Here is my code for the glyphs:

byte one[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};

byte two[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};

byte three[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};

byte four[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};

byte five[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};

and here is the code for the "Boot screen"

void bootScreen(){
lcd.clear();
lcd.setCursor(1,0);
lcd.print("Device booting up.");
lcd.setCursor(3,1);
lcd.print("Please wait...");
for (int f = 0; f < 20; f++){
lcd.setCursor(f,2);
lcd.write(byte(1));
lcd.setCursor(f,3);
lcd.write(byte(1));
delay(50);

lcd.setCursor(f,2);
lcd.write(byte(2));
lcd.setCursor(f,3);
lcd.write(byte(2));
delay(50);

lcd.setCursor(f,2);
lcd.write(byte(3));
lcd.setCursor(f,3);
lcd.write(byte(3));
delay(50);

lcd.setCursor(f,2);
lcd.write(byte(4));
lcd.setCursor(f,3);
lcd.write(byte(4));
delay(50);

lcd.setCursor(f,2);
lcd.write(byte(5));
lcd.setCursor(f,3);
lcd.write(byte(5));
delay(100);
}
}

sorry that there is so much code.

just a thought, (not sure if it is worth anything) but is it possible that using 8 bit as opposed to 4 bit mode will fix it?

It's very unlikely that using 8 bit mode will get any improvement.
To me this looks like the screen doesn't load the custom glyphs right after power up, but it will do that after resetting.
Are you initialising that LCD correctly ?
What if you pause a bit after initialising the LCD and before uploading the glyphs to it ?
Are you doing that in this order at all ?

Can you show the part of your sketch where you do the initialising and the uploading ?

here is the pin association:

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);

and the initialization:

lcd.begin(20, 4);

i put the createChars after the lcd.begin. would it be better to put it before the lcd.begin?

i put the createChars before the lcd.begin and added a 5 millisecond delay after the lcd.begin and it now works like a dream. thanks for the help.

EDIT: i found that 5 ms was still a bit weird every now and then so i bumped it all the way up to 20(which is probably totally overkill but i would rather be safe than sorry and the startup time is not noticably longer)

EDIT 2: I found once again that 20 is still a bit low so i bumped it WAY up to 100.

ryan27968:
EDIT 2: I found once again that 20 is still a bit low so i bumped it WAY up to 100.

Somewhere in the datasheet it gives an indication of just how long the LCD takes to initialise. I think. The other concern is just how quickly the power supply ramps up.

Rather than saying "sorry that there is so much code", can you go back and "modify" your first post and change the "quote" tags to "code"?

The custom characters are stored in volatile memory. Why would they not get corrupted when power is lost?

Don

ryan27968:
i put the createChars before the lcd.begin and added a 5 millisecond delay after the lcd.begin and it now works like a dream. thanks for the help.

begin() is what initializes the hd44780 interface and the display.
The createChar(), call needs to be after the begin() call since begin() is what
ensures that everything is initialized and in the proper state and
that the rest of the library can always properly communicate with the module.
There is no way to guarantee that commands or data can be correctly be delivered
to the module, particularly in 4 bit mode, prior to the initalization sequence that is
done in begin().

There is something else going on here.
Can you post the full sketch that isn't working?

--- bill