Go Down

Topic: Graphic LCD (KS0108) library now available (Read 115672 times) previous topic - next topic


Hi Everyone,

Big thanks to the gLCD crowd for helping me with my random display. It's going to MJ now so he can get it working and post the results.
I am playing with a KS0108 now which is Pin Out B, not because I have the manual but because the display lights up that way around!

I am getting garbled pixels. Piccy.

Anyone seen this before.




Jul 31, 2010, 12:56 am Last Edit: Jul 31, 2010, 01:44 am by maujabur Reason: 1

I found this datasheet for your display (from the picture you sent me):

It's almost Pin out B, but it does not have the CS1 and CS2 lines.

I read somewhere that this controller (st7920) is compatible with the ks0108 instructions [edit] [update:maybe it's not][/edit] , but I'm not sure how to make it work here. Maybe you have to select somewhere that your LCD has only one chip and NO CS...

I'll try to learn more about it, but maybe someone could help...


Aug 01, 2010, 11:24 am Last Edit: Aug 01, 2010, 11:36 am by bperrybap Reason: 1
Be very careful about hooking up the glcd. Connecting pins incorrectly
can blow up the glcd, its internal controller, or even the AVR chip.

I'm a bit confused here about which glcd you are running vs
what MauJabur is looking at.

Before I can help you with the display related to the picture you posted, I'll need some additional information.
- Which library are you using? The ks0108 or the new beta glcd library?
- Which specific glcd module are you using?
 and a link to a data sheet for that display.
- How you have wired up the panel.
- What code/Sketch are you running when you see this?

If it is the glcd  in the data sheet that MauJabur posted a link to (JHD529M1), then it is not compatible with a ks0108.

None of the commands in the JHD529M1 are the same as a ks0108.
The way to get that chip supported would be to add support
for it into the new GLCD library vs attempting to add it back into the ks0108 library.

As far as your display with the "snow" on it, yes
I have seen similar results to what you are seeing.
Some GLCDs power up with an alternating block pattern.
Yours may do this. Then if things are incorrectly wired up, the hardware timing is off or if the display is not ks0108 compatible, then you can see trash
pixels being lit up on the screen which kind of look like "snow".

My recommendations is to move to the beta glcd library (if you aren't already using it) as it has much better diagnostic capabilities,
including a diagnostic sketch and you should not have any hardware timing issues as the new code should properly honor
all the hardware timing automatically.

And for any discussions related to the beta glcd library,  post over
on the beta library thread vs this thread, just to keep things
separate since the two libraries are fairly different especially with
respect to configuration capabilities and diagnostic information.
Link to beta thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1279128237/

--- bill


just FYI, i tried it with AGM1264B model of this 128x64 Graphic LCD... and it works perfectly.

Thanks for the library and the different ideas posted in this forum.



Aug 01, 2010, 08:21 pm Last Edit: Aug 01, 2010, 08:24 pm by mem Reason: 1
@madepablo, did you try the existing release (version2 ) or the Beta release of version 3. If you have not tried version 3, I think you will be pleased.  We are looking test feedback so it can be formally released - give it a try

see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1279128237/

edit: I note that you replied in the other thread so ignore this


Aug 01, 2010, 08:26 pm Last Edit: Aug 01, 2010, 08:27 pm by madepablo Reason: 1
Hi mem,

In this post i used version 2.

But a couple of minutes ago, i also tested the new version, and it also works fine!!! Thanks!
See my configuration in the other post.

Just only.. i wired the pin 19 to ground with a 330Ohms resistance, and pin 20 to +5V... but backlight doesn`t light... how should i have the backlight running?


Aug 01, 2010, 08:33 pm Last Edit: Aug 01, 2010, 08:34 pm by mem Reason: 1
Just only.. i wired the pin 19 to ground with a 330Ohms resistance, and pin 20 to +5V... but backlight doesn`t light... how should i have the backlight running?

Check your datasheet but many GLCD panels use pin 19 for +v to the backlight and pin 20 for ground. The resistor can go on either side


My datasheet say:

19 K  BL Cathode
20 A  BL Anode

It runs now. Seems that 330ohms is so much... y used 5,6 ohms in agreement with the datasheet, what propose 5ohms for +5V Vcc. Now it works perfect.



@bperrybap about Thom:

he sent me this picture:

And after identifying the controller, this library worked:



I've had a chance to look closer at the st920 chip interface.
It is very different from a ks0108 style type of display.
It has some higher level commands, ,built in fonts,  user definable
fonts plus bitmap graphics capability.
It also has 3 interfaces: 8 bit, 4 bit, & serial.

The ks0108 type of device is a very "dumb" interface.
It is just a big bit mapped memory display with an 8 bit interface.

While it looks like a nice feature superset compared to a ks0108,
there will be some challenges trying to get this type of device
integrated into the glcd library (the ks0108 library really isn't a good option).

Because the ks0108 is a dumb bit mapped interface, the ks0108 type of device requires doing everything yourself. Which includes rendering fonts from font data stored in the user code (sketch).

The ks0108 on board graphic memory is based on 8 bit display pages that when the display panel is viewed with a wide aspect ratio (vs tall), the 8 bit pages draw 8 vertical pixels on the screen with bit 0, being the the top most pixel. Every time a page is written the address counter advances to the right.

In my initial look at the st920, it appears that it uses a 16 bit page split across 2 writes and also advances the address counter to the right. The real challenge with respect to a "ks0108" style library is that it appears that the 16 bit page draws 16 pixels horizontally when the display panel is viewed horizontally with the left
most pixel being bit 15.
This is a fundamental difference between it and the ks0108 style glcd pages.

The difference between vertical and horizontal pixel page display mapping is potentially a big deal depending on how the code is written.
Currently the ks0108 & glcd library code does not use a frame buffer.
This was very intentional to allow it run on smaller MCUs and not consume extra RAM memory regardless of the display panel geometry.

Because the ks0108/glcd code does not use a frame buffer, there are several places in the code that "understand" the page to pixel mapping direction and do pixel to page mappings on the fly, the biggest being the character rendering code.

Also, the font data created is currently generated for 8 bit vertical pages.

It is still possible to slide in support for a horizontally page mapped device, but it won't be a drop in. And there will have to be some design design decisions made as how to best fit it in.
Things like having different font data that maps to this style of device or map the font data from 8 bit vertical pages, to 16 bit horizontal pages on the fly as characters are rendered.

There is also a potential issue of how to handle the st920 built in fonts vs custom graphic rendered fonts. The built in fonts have some limitations on them that the glcd library fonts do not. Like pixel location and size. The glcd library can render any sized font on any x,y pixel value. The st790 has very limited number of internal fonts and has distinct boundaries where fonts must be drawn.
The glcd library also provides some options like inverse video mode and reverse (top to bottom) scrolling within user defined text areas that isn't supported by the st920 built in fonts.

But the st790 is not alone in these types of compatibility issues with the current ks0108/glcd library code. There are several other displays that have these capabilities including some that do not have read capability so it may be that adding support for this type of device is tied in with a bigger picture view of how to add support for this class of device and devices that do not provide read capability, rather than looking at it from the viewpoint simply getting support for the st790.

--- bill


I am trying to use this library with a 128x64 LCD from Sure Electronics. This one :-


But I am getting nothing on the display except every pixel being lit. Everything seems to be connected as it should be. I'm using a Mega.

Any ideas?


Aug 23, 2010, 08:17 pm Last Edit: Aug 23, 2010, 08:18 pm by mem Reason: 1
Mike, try it with the beta version of the next release - see this thread:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1279128237/0

The most common cause of problems is wiring, double check that you have the LCD pins connected to the correct pins for the mega


I know this sounds like a very dumb question... I am a total beginner... I just got my very first 128x64 LCD and Arduino board today! (Worked with 8051 and 16x2 LCD before) And this is my very first comment on this forum!  ;D

From ReadMe:

To install this library, just place this entire folder as a subfolder in your Arduino hardware/libraries folder.

When installed, this library should look like:

Arduino/hardware/libraries/ks0108                                (this library's folder)
Arduino/hardware/libraries/ks0108/ks0108.cpp             (the library implementation file)
Arduino/hardware/libraries/ks0108/ks0108.h                 (the library header file)
Arduino/hardware/libraries/ks0108/ks0108_Panel.h       (the Panel configuration header)
Arduino/hardware/libraries/ks0108/ks0108_Arduino.h   (header used to define pins for Atmega168/328)
Arduino/hardware/libraries/ks0108/ks0108_Mega.h      (header used to define pins for Mega)
Arduino/hardware/libraries/ks0108/ks0108_Sanguino.h (header used to define pins for Sanguino) - untested
Arduino/hardware/libraries/ks0108/SystemFont5x7.h     (definition for 5x7 system fonmt)
Arduino/hardware/libraries/ks0108/Arial14.h                 (the definition for 14 point Arial Font)
Arduino/hardware/libraries/ks0108/keywords.txt           (the syntax coloring file)
Arduino/hardware/libraries/ks0108/examples                 (diectory containing the example test sketch)
Arduino/hardware/libraries/ks0108/readme.txt               (this file)

However, I can't find Arduino/hardware/libraries/...
Can anyone tell me where I should place my extracted folder?  :P

HELP NEEDED... Thanks!

PS. I am using Arduino-0019


Contributed libraries such as this one are now located in a directory called libraries in the directory that contains your sketches.

See the section on Contributed Libraries in this link: http://www.arduino.cc/en/Reference/Libraries


:-?Thank you! So, I have to open a "libraries" folder then import the library in arduino program. :-?

Go Up