GLCD library version 3 (end of life - no longer supported)

At last after a day trying to get my old GLCD working on my new Uno I find this thread and the link to a working library!!

Am working through the "Arduino Cookbook" which I find very useful but the libraries are not included in the downloads.

Much Googling and trying Version 2 and version 3 beta of GLCD libs ( they wouldn't compile ) but just downloaded from this thread and bingo!!

After about 6 years my GLCD spoke to me!!

Many thanks

Will

I'm having a lot of problems to get my display work with Arduino UNO rev3.

I have this display: http://www.sparkfun.com/products/710 bought from sparkfun.
I did all the connection like specified in the documentation for the panelA but I always have all dark pixels and i read nothing else also when i upload the hello world sketch.

if i carefully rotate the potentiometer i can only have two situations: all pixels dark and all pixel blank.

All the connections are correct and this is the diagnostic report:

Initializing GLCD
Displaying ChipSelect Screens
Serial initialized

Reported Arduino Revision: 1.0

GLCD Lib Configuration: glcd ver: 3 glcd_Device ver: 1 gText ver: 1
GLCD Lib build date: Mon Dec 5 01:50:07 CST 2011
GLCD Lib build number: 442
Panel Configuration:ks0108
Pin Configuration:ks0108-Arduino

GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:14(PIN_C0) CSEL2:15(PIN_C1)
RW:16(PIN_C2) DI:17(PIN_C3) EN:18(PIN_C4)
D0:8(PIN_B0) D1:9(PIN_B1) D2:10(PIN_B2) D3:11(PIN_B3)
D4:4(PIN_D4) D5:5(PIN_D5) D6:6(PIN_D6) D7:7(PIN_D7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(14,0x1, 15,0x0) CHIP1:(14,0x0, 15,0x1)
Data mode:
d0-d3:nibble mode-Non-Atomic
d4-d7:nibble mode-Non-Atomic

Diag Loop: 1
Initializing GLCD
Displaying ChipSelect Screens
Walking 1s data test
Compare error: 0 != 1
Compare error: 0 != 2
Compare error: 0 != 4
Compare error: 0 != 8
Compare error: 0 != 10
Compare error: 0 != 20
Compare error: 0 != 40
Compare error: 0 != 80
TEST FAILED

Reported Arduino Revision: 1.0

GLCD Lib Configuration: glcd ver: 3 glcd_Device ver: 1 gText ver: 1
GLCD Lib build date: Mon Dec 5 01:50:07 CST 2011
GLCD Lib build number: 442
Panel Configuration:ks0108
Pin Configuration:ks0108-Arduino

GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:14(PIN_C0) CSEL2:15(PIN_C1)
RW:16(PIN_C2) DI:17(PIN_C3) EN:18(PIN_C4)
D0:8(PIN_B0) D1:9(PIN_B1) D2:10(PIN_B2) D3:11(PIN_B3)
D4:4(PIN_D4) D5:5(PIN_D5) D6:6(PIN_D6) D7:7(PIN_D7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(14,0x1, 15,0x0) CHIP1:(14,0x0, 15,0x1)
Data mode:
d0-d3:nibble mode-Non-Atomic
d4-d7:nibble mode-Non-Atomic

Diag Loop: 2
Initializing GLCD
Displaying ChipSelect Screens
Walking 1s data test
Compare error: 0 != 1
Compare error: 0 != 2
Compare error: 0 != 4
Compare error: 0 != 8
Compare error: 0 != 10
Compare error: 0 != 20
Compare error: 0 != 40
Compare error: 0 != 80
TEST FAILED

Reported Arduino Revision: 1.0

GLCD Lib Configuration: glcd ver: 3 glcd_Device ver: 1 gText ver: 1
GLCD Lib build date: Mon Dec 5 01:50:07 CST 2011
GLCD Lib build number: 442
Panel Configuration:ks0108
Pin Configuration:ks0108-Arduino

GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:14(PIN_C0) CSEL2:15(PIN_C1)
RW:16(PIN_C2) DI:17(PIN_C3) EN:18(PIN_C4)
D0:8(PIN_B0) D1:9(PIN_B1) D2:10(PIN_B2) D3:11(PIN_B3)
D4:4(PIN_D4) D5:5(PIN_D5) D6:6(PIN_D6) D7:7(PIN_D7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(14,0x1, 15,0x0) CHIP1:(14,0x0, 15,0x1)
Data mode:
d0-d3:nibble mode-Non-Atomic
d4-d7:nibble mode-Non-Atomic

Diag Loop: 3
Initializing GLCD
Displaying ChipSelect Screens
Walking 1s data test
Compare error: 0 != 1
Compare error: 0 != 2
Compare error: 0 != 4
Compare error: 0 != 8
Compare error: 0 != 10
Compare error: 0 != 20
Compare error: 0 != 40
Compare error: 0 != 80
TEST FAILED

Reported Arduino Revision: 1.0

GLCD Lib Configuration: glcd ver: 3 glcd_Device ver: 1 gText ver: 1
GLCD Lib build date: Mon Dec 5 01:50:07 CST 2011
GLCD Lib build number: 442
Panel Configuration:ks0108
Pin Configuration:ks0108-Arduino

GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:14(PIN_C0) CSEL2:15(PIN_C1)
RW:16(PIN_C2) DI:17(PIN_C3) EN:18(PIN_C4)
D0:8(PIN_B0) D1:9(PIN_B1) D2:10(PIN_B2) D3:11(PIN_B3)
D4:4(PIN_D4) D5:5(PIN_D5) D6:6(PIN_D6) D7:7(PIN_D7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(14,0x1, 15,0x0) CHIP1:(14,0x0, 15,0x1)
Data mode:
d0-d3:nibble mode-Non-Atomic
d4-d7:nibble mode-Non-Atomic

Can you help me, please?

Sounds like the power and contrast pins are wired up correctly.

The diags seems to be reading all zero bits.
This is more than likely due to some miswiring.

Check the wiring very carefully, to ensure that the wires
from the Arduino pins are connected to the glcd function pins as
indicated in the diagnostic output.
Pay particular attention to the control lines: R/W, DI, EN, CS1, CS2

Is there anything else hooked up to the Arduino?

Can you post some clear closeup photos of your wiring as well as wide shot
that shows all the wiring?

--- bill

Thanks for your reply.

All the wires are connected and soldered as specified in the library docs for panelA displays.

Sometimes, it happens that if i upload "life" example, the display works very well but if i shutdown and power on arduino again, it does not work and display strange characters.

It works very randomly.

Sounds like some sort of intermittent issue.
If diags is reporting an error, there is still a problem.
Since it sounds like it works some of the time, here are some likely possibilities:

  • wiring issue
    This could be anything like a loose wire or improper solder joint, using wires that are too long,
    to an actual mis-connected wire.
    In particular, what is the glcd modules reset pin (glcd module pin 14) connected to?
    Some glcd modules are very picky about the reset signal.

  • bad or insufficient power.
    Can you measure the voltage between pin 1 and pin 2 of the glcd module?
    Is everything powered from the same power supply?

  • bad glcd module.
    This tends to be quite rare but it does happen.
    Was the glcd module ever mis wired and powered up? even briefly?

Can you post some clear photos of your setup with closeups of the solder connections
on the glcd and a photo that clearly shows all the wires and their connections?

--- bill

I just noticed this:

Initializing GLCD
Displaying ChipSelect Screens
Serial initialized

In your diag output. This sequence of messages does not occur in the code.

"Serial initialized" prints first but in your output it occurs after the other two messages.

Did you reset the board in the middle of the diag sketch running?

--- bill

No, I don't.

However, pin 14 of my LCD is connected to Arduino reset. Is it correct?

(I tried also to connect pin 14 to +5VDC, but it's the same)

The problem is that sometimes the library works well (few times) and all the other times it prints weird characters..

????
Weird characters? I think it may be time for some photos/video.

What about: (from earlier)
The supply voltage?
The source of the voltage?
Was the module ever incorrectly hooked up?
Any photos of your setup?

These are some photos about the display.
The first and the second photos are for Hello World example while the third is for Life example.

I didn't take the photo about the wiring since it is not possible to understand something since there a lot of wires, all with the same colour.
However, they are all ok since display works fine sometimes.

I have no other device attached to my Arduino UNO rev3, only the display.
I have Serial library since i write something on the serial port just to see if my program is working.

Supply voltage is +5VDC from Arduino which is also the source voltage; i'm not using any additional source.
The module was never been connected with a wrong configuration.

That is very strange.

The glcd memory is mapped 8 bits at time vertically. Each 8 vertical pixels is
written at once. The text is corrupted within that 8 bits.

It still could be a wiring issue.
Broken, disconnected, or poor connecting wires can create some really strange problems
as the signals float around and vary depending on loading and what is being done.

Diags is going to be the best bet for diagnosing the problem.

From looking at the display data bits 2 and 3 (glcd module pins 6 & 7) seem to be having issues.
Take a very close at the wires on those connections.

When diags runs what does the initial animation pattern look like?
(It should be a triangle from upper left to lower right).

Does diags get past the initial walking ones test?

You measured the voltage at pins 1 & 2 on the glcd at exactly 5v?

Can you get a clear shot of the wires so I can see the solder joints?
What is on the other end of the wires?
Are the wires going into a breadboard, or directly into the Arduino board?
How long are the wires and do they have any breaks or re-connections in them before
being connected to the Arduino headers?

--- bill

Between pin1 and pin2 there are 5.01VDC.
I check the continuity with a tester on all the connections and they are all ok.
Unfortunately, i tried to take a photo about the wiring but it is not clear since there are too many wires.
Pins 6 and 7 are ok.
Wires are very short, about 10 centimeters and they do not have reconnections or breaks: they directly go to the atmel microcontroller.

I'm using a perfboards, so all the wire are soldered.
However, i tried to connect and re-connect the display to my arduino several times and all the time connections are ok but there are strange characters on the display.

The most important thing is that when I run the diagnostic sketch, I'm able to see the triangle which is under all the strange characters and the black pixel lines.
As you can see in the previous photos, sometimes the correct characters are in background since strange characters and black lines are foreground.

These are the connections i did:

Pin 1...5V
Pin2...GND
Pin3...cent pot
Pin4...D8
Pin5...D9
Pin6...D10
Pin7...D11
Pin8...D4
Pin9...D5
Pin10..D6
Pin11..D7
Pin12..A0
Pin13..A1
Pin14..5V
Pin15..A2
Pin16..A3
Pin17..A4
Pin18.. pot
Pin19..5V
Pin20..resistor to gnd

Do you have a macro mode on your camera? (most cameras have it)
You will need to use that to get a clear close up image.
I'd really like to see the solder joints on the glcd the other end of the wires as well.
Take it from the back of the board where the wires are soldered since that is most interesting thing to see.
There shouldn't be any wires in the way on that side.

I'm using a perfboards, so all the wire are soldered.

Wait, earlier you said you were using an Uno Rev 3.
Are you now using an embedded design on a perfboard with your own circuit?

Please show a photo of you full setup. All boards/wires/components involved.
You have not yet shown this.

However, i tried to connect and re-connect the display to my arduino several times and all the time connections are ok but there are strange characters on the display.

Not sure what you mean by this.
Do you mean that you are using different boards or you are disconnecting everything and reconnecting it?

The most important thing is that when I run the diagnostic sketch, I'm able to see the triangle which is under all the strange characters and the black pixel lines.

Note sure what you mean by this.

As you can see in the previous photos, sometimes the correct characters are in background since strange characters and black lines are foreground.

Actually I see the correct characters every time. What I see is that certain pixels within the character are missing and there are some
stray pixels showing up. This kind of effect can be caused by incorrect wiring, broken wires, wires not making proper connections,
or wires shorted to adjacent wires.
It could also be caused by a bad glcd or a burned up or malfunctioning Arduino pin.
But almost always it is due to incorrect/improper wiring.

In looking closer at your images it looks like glcd data bit 2 is not working correctly.
That is glcd module pin 6 which is connected to arduino digital pin 11.
That wire seems to be either broken, not soldered correctly, or perhaps shorted to glcd data bit 1 or data bit 3.
Look very closely at that wire to make sure it is not shorted to a wire next to it and re-solder its connections.

Do you have a logic probe?
This could be used to test the Arduino pins to verify that the arduino pins are working.
In particular arduino digital pin 11.

--- bill

I tried searching the forum and didn't quite find anything.

glcd takes up a tonne of pins, and I'd like to move all the data pins onto a demultiplexer. Now there are 4 pins instead of 8.

I can understand that this could incur a bit of a performance penalty, but I'm not trying to make a game here, just an unnecessarily large menu system :wink:

So I wanted to see if I could just modify the library and make it work.

I came across this write8bits function in avrio.h, was wondering if that's used specifically for the 8 data ports on the glcd?

If not, perhaps I could get some info of where to look to change the way those data ports are used?

thanks

avrio is at the very lowest level. That is not the point that would be modified.
The upper layer routines in gText and glcd call routines in glcd_Device
It is the glcd_Device class that talks across the h/w interface using functions
like ReadData() and WriteData(), SetDot(), SetPixels(), etc...
Even those functions don't call avrio routines directly.
They use wrapper macros defined in glcd_io.h to hide the low level i/o and to deal with
with the control line mappings in the panel configuration files.

To change the h/w interface, you need to slice it at either the glcd_Device layer
or replace the glcd_io macros.

I'd recommend altering the glcd_io macros to match what ever hardware
you are looking at implementing.

From a hardware perspective the biggest challenge if trying to multiplex pins is
how to deal with the bi-directional needs. i.e. the data has to read as well as written.
You can turn on the GLCD_READ_CACHE option which will eliminate the data reads
at the expense of using up SRAM, but that doesn't completely solve the need for reads
in that the code will still need read access to the BUSY status which requires
reading data bit 7.

--- bill

bperrybap:
avrio is at the very lowest level. That is not the point that would be modified.
The upper layer routines in gText and glcd call routines in glcd_Device
It is the glcd_Device class that talks across the h/w interface using functions
like ReadData() and WriteData(), SetDot(), SetPixels(), etc...
Even those functions don't call avrio routines directly.
They use wrapper macros defined in glcd_io.h to hide the low level i/o and to deal with
with the control line mappings in the panel configuration files.

To change the h/w interface, you need to slice it at either the glcd_Device layer
or replace the glcd_io macros.

I'd recommend altering the glcd_io macros to match what ever hardware
you are looking at implementing.

From a hardware perspective the biggest challenge if trying to multiplex pins is
how to deal with the bi-directional needs. i.e. the data has to read as well as written.
You can turn on the GLCD_READ_CACHE option which will eliminate the data reads
at the expense of using up SRAM, but that doesn't completely solve the need for reads
in that the code will still need read access to the BUSY status which requires
reading data bit 7.

Thanks for the input.

I did not think about reading. Ultimately I need 3 pins for the shift register to arduino I suppose.

Perhaps I can reduce CS1/CS2/RW/RS/E/RST down to 3 and leave the 8 data pins alone? Not as big saving, 6 to 3 as opposed to 8 to 3, but still better than nothing? Means glcd would need 12 pins.

I'm guessing a Uno is not fast enough to do this serially?

I need to create a device with a LCD text display where I can highlight in some fashion strings of characters. By highlight I mean either underscore an entire string or invert black/white foreground/background of multiple characters. As best I can tell none of the text only LCDs available about me to do that. The cursor is only a single character so I cannot underline an entire word or sentence. And I've not found any of them that allow me to invert the text foreground/background.

So it looks like I'm going to have to use a graphics display and handle all of that myself (which I'm not looking forward to).

Before I go to the trouble of buying a display, wiring it without an i2c (again not looking forward to that) can someone please verify for me that the GLCD will let me to display text easily with some of the words inverted?

And although this may not be the place to ask, does anyone know of a text display that will do what I want so that I don't have to go the route of a graphics display?

cyborg5:
So it looks like I'm going to have to use a graphics display and handle all of that myself (which I'm not looking forward to).

It is not difficult to have reverse text with the glcd library.

Before I go to the trouble of buying a display, wiring it without an i2c (again not looking forward to that) can someone please verify for me that the GLCD will let me to display text easily with some of the words inverted?

Yes the glcd library can do this. It is quite easy to invert text. you simply set inverse mode and then start printing to the display again.
Set normal and you are back to normal.
Here are some examples I found on YouTube that use this capability:
Some menu code:

The diags I ship with the library:

(in the diags video look at the display at around 10 seconds)

And although this may not be the place to ask, does anyone know of a text display that will do what I want so that I don't have to go the route of a graphics display?

hd44780 type displays can't do this. They can turn on a cursor. They can set the cursor type, they can move/pan the text left/right
but they can't underline or invert the text.
For menus on text displays you can use brackets to "higlight" the text. ie

[this is hightlighted]
 this is not

--- bill

Thanks for confirming my speculations. And also for the [highlighting] idea. I have created some menus which just used a -> arrow character or a custom bit pattern that looked like a pointer but for multiple word options on a 16x2 display it wasn't very useful. I should've thought of brackets or parentheses or something especially since I'm going to be using a 20x4 which gives me a little more room to play with. I think I'm going to stick with text displays for now, get things running well, and then think about making an upgraded version using graphics. Maybe by that time someone will come up with a really easy to use graphic shield with a build in i2c to cut down on the overhead.

v0idnull:
I did not think about reading. Ultimately I need 3 pins for the shift register to arduino I suppose.

Perhaps I can reduce CS1/CS2/RW/RS/E/RST down to 3 and leave the 8 data pins alone? Not as big saving, 6 to 3 as opposed to 8 to 3, but still better than nothing? Means glcd would need 12 pins.

I'm guessing a Uno is not fast enough to do this serially?

"fast" is a relative term. There is no minimum speed that things need to happen on a ks0108 type interface.
You could take days to set the pins and latch a byte, the display would not care.
The interface timing is based on a minimum amount of time that must pass before something can change or be done.
i.e. you must not do anything in a period of time shorter than a certain amount.
For example if you want to send a byte you set up the control lines then you are supposed to wait 140ns before you present
the data. That 140ns is a MINIMUM not a maximum. So you can take longer.
All the timing is based on minimum delays.

There are ways to interface the module to the library using less pins. I've thought quite a bit.
I know a few ways of how to do it and have thought about creating a low cost backpack.
There is even a way to control a shift register with only 1 pin vs having to use 3 pins.
I have a LCD backpack design for a hd44780 character lcd that does this as fast as the stock Arduino 4 bit parallel mode.

The real challenge for a glcd backpack from product standpoint is that there are so many different pinouts.
While 2 pinouts are by far the most popular, I've seen over 11 different ones for the ks0108.

Technically, the biggest challenge is how to deal with reading the glcd memory and not gobbling
up so much memory, because memory is so limited on the m168/m328 arduinos.
Its not hard, but having to turn the data bus around costs extra components or is VERY slow in the case
of something like i2c as i2c is quite slow particularly at the standard 100kHz bit rate.

It comes down to 3 things

  • time/speed
  • AVR memory
  • component costs

You can't optimize all 3 at the same time.
(The current model with 13 pins is when all 3 are optimized)

--- bill