Go Down

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


Is there any possibility to use the GLCD with shift registers? For me it is too complicated to change the libary because I can't understand it.

I have to use the pins for some buttons to make a display menu. And I want to read some fan speeds and temperatures

at the moment

pin 0 - 7 Display Data pins
pin 8 - 12 Display Command pins
analog pin 5,4 tempertatures
analog pin 3 - 1 fan speed

==> 2 pins left. But I have to set again 2 potentiometers and min 2 Buttons. Thats why I have to get new pins.
The fan speed pins can also be set to digital pins.

I hope you understand my problem.

If not ask me.


It has been done although I have not tried it myself. See posts starting from here for more: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210427907/63#63

Another approach is to use a board with lots more pins, such as the sanguino or mega.


Thanks a lot I overread this post.

But it wont work. I don't know why.
I get lots of errors.

Is it possible that you try it.

Propably it cant work with the new libary.

I will give some pictures if I'm ready.


Unfortunalty I don't have any spare time at the moment to do any work on integrating shift registers with this library. Did you try and contact the person that posted that code to see if he can help?



I will try to cantact the person who postet the hack.


I tested my old hack with the new KS0108 lib and it works just fine.
I also tried to move the CSEL1 and CSEL2 to the digital pins and it was easy.
Then I tried to move the D_W, D_I an EN to the digital side but was not able to get it to work.

mem do you have an idea of why it is not possible to just change the D_W, D_I and EN pins from the analog side to the digital side by just changing the pin settings in the h-file???


All the command pins share the same code so if CSEL works then the others should also.

I have a version running here on a standard Arduino board with EN on digital pin 2 and it works without problems.  The command pins have been tested on digital pins 30-37 on the Mega board. What board and controller are you using?


I'm using Diecimila board with a 168 controller.

If I use CSEL1 and 2, E_W, D_I and EN on Port C it works.
If I use Port B or D it don't work, no text or symbols appear on the GLCD.
But if only the CSEL1 and 2 is moved to Port B or D it woks.

They are all set with "fastWriteHigh" or "fastWriteLow" and therefore I cant understand why it won't work.


In ks0108_Arduino.h  lets see what happen if we try this test:

Comment out the two lines defining fastwriteHigh and fastwriteLow and replace with:

#define fastWriteHigh(_pin_) digitalWrite(_pin_, HIGH)
#define fastWriteLow(_pin_) digitalWrite(_pin_, LOW)

Try that with your pin assignment and let me know if that works (it may be slow but I just want to know if you can see anything)

Are you testing this with the GLCD directly connected or with a shift register?


No the result is the same, nothing on the screen.
I tried with a lot of different pin assignments but the result is still as described in reply #187.

I'm using a shift register. Do you think that the shift register can cause this kind of problems.
If the shift register creates this problem, it may be a synchronization problem. Something that goes too fast or too slowly.


Aug 15, 2009, 12:52 am Last Edit: Aug 15, 2009, 12:55 am by mem Reason: 1
I wonder if it is the shifting code, can you post your sketch.


I am using your example sketch for testing. But the shifting code is in the lib.
I altered your new KS0108 lib according to reply #63 http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210427907/63#63, all the shift register code is in the ks0108.h file. That code is from MartinFick in the "higher performance IO" thread.

The only thing I did to change the pin assortment was to change the top of "ks0108_Arduino.h" to the digital pins instead of the analog ones.
The Shift register pins is defined in the ks0108.h file (pin 2,3 and 4).

If you want I can send you a private mail with all the code, maybe its easier to look at it when it is implemented.


I just realized that you may not be reading the LCD status. Have you modified the WaitReady function so it reads the busy flag (this requires either an additional pin on the arduino or some clever wiring)

Yes, pm me the files you changed and I will have a look.


Frisken, It looks like you have not modified the read routines and this may be why its not working.  I think there is a problem with this shift register solution because of the architecture of the ks0108 chipset.

The library read a byte of data from the chip before each write. If you study the datasheet you will see why the library has to do this to prevent overwriting adjacent pixels.  I don't think your code actually accesses the data  so the output routines will not be correct.  

One way to overcome this is to create a copy of the pixel data in Arduino RAM, but this requires 1K of memory dedicated for this, so won't work on a ATmega168.

Anther way is to use a bi-directional shift register to get the data back into the arduino but that will be complicated and slow.

Perhaps I missed the place in your code that addresses this problem, can you actually duplicate the image shown in the playground (using any pins of the pins to drive the shift register)? if so, perhaps put some delays in the sketch to slow things down and take a picture so I can have a look.  


I changed all the reads to be static 0x00 instead of "this->ReadData()" and thereby it is not possible to do readings from the GLCD. If I only ever write to any of the 8 adjacent pixels once, then I don't need to read the LCD data. I use a fixed width font that I got from you in reply #64. I works great if the amount of characters on a row is known. Look at reply #47 to #50.

My app only uses text and some small graphics and I have no problem using the analog pins for the GLCD. Therefore I have not seen this problem until Lorz contacted me. Lorz have to use the analog pins for other stuff and therefore I tried to use only the digital pins, but it do not work for some strange reason.

Go Up