Mega 2560 with ST7920 LCD and u8glib problem

I bought 128x64 LCD with ST7920 controller from China. It is connected to arduino Mega, but there is a problem, which I dont know how to solve. I am using U8glib and sometimes everything works fine, but sometimes there are displayed some stripes or random characters. At first I thougt there is a problem with wires, but now it seems something else is causing this.
Usually after first boot (when I disconnect the power), the screen is full of some "chinese" characters. Reseting the arduino usually solves this, but sometimes I have to reset the microcontroller many times. A have replaced the wires and changed data PINs (3 cables), but nothing changed. Now I ran out of ideas and I would really appreciate your help.

Hi

U8glib sends an init sequence to the display immediatly after reset. This init sequence might be corrupt or is not recognized by the display.

Some possible problems:

  1. Your arduino is too fast, the display is not yet ready to receive the init sequence:
  2. The reset of the display takes too long, the init sequence has been sent, but was not received.
  3. Wires are unstable (connect problems) or are too long.
  4. Timing of the data transfer is too fast for your display
  5. Mode selection (parallel vs. serial) has a problem (or is missing or floating...)

I would start with the hardware: Check wires and their connection. Did you correctly set the mode for your display?

You might also provide more information: What is the mode? Parallel, seriel? Can you provide a picture?

Oliver

I've been testing this for the past two days and now LCD worked fine everytime after first reset. The point is, if arduino is not connected to the power source, the screen usually doesn't work when I plug it in. After first reset, it is back to normal. I have to check what happens when it is turned on for a longer time.
Regarding your post, I would say there could be something with the init sequence...

LCD is in serial mode.

here you can see, what happens after powering the arduino on. Sometimes these characters are covering all the screen, not just part of it...

I am also getting the same problem with my ST7920 graphic display operating in serial mode,
Ph4nt0m Did you manage to cure your display problem?

Hi

Additionally to the mentioned problems, some ST7920 require an additional delay after writing a byte. I have fixed this in the attached version of u8glib. (line 117 in Google Code Archive - Long-term storage for Google Code Project Hosting.)

Frome some other reports, i also heard, that shorter wires improve the situation.

Oliver

u8glib_arduino_v1.09pre10.zip (692 KB)

Hi Oliver

Thanks for taking the time to reply, I will try the revised library and see what happens.
At the moment to get over the problem I have to remove the 5volt supply to the GLCD whilst my program is running, wait a second and then restore the 5volt supply , once the display is showing the correct information it will function Ok, it just appears to be a problem on first power up.

One question, could this probelm be caused by the fact I am not using the display reset (not present on the serial socket which is on a PCB on the back of the display)

U8GLIB_ST7920_128X64 u8g(0, 1, 2, U8G_PIN_NONE);

Many thanks
Jason

A "display module" usually has a reset circuit included. Often "COG (Chip On Glass) Displays" do not have such a circuit. Then: Some controllers do need a reset circuit other do not need that circuit. At the end i have only seen one display which really needs a good reset (PCF8812). So i do not think its a reset issue.

Oliver

Thanks for explaining that.

The only other thing to mention, is when this problem occurs, on first power up, it only seems to effect the top half of the screen displaying random pixels, the bottom half displays my correct information.

I will post a photo as soon as I can.

When I pull the 5 volt out and back again whilst sketch is running all is displayed correctly.

Jason