Go Down

Topic: GLCD library version 3 help (Read 4238 times) previous topic - next topic


I needed help with the GLCD library version 3 I am also new to the Ardunio world, I have an KS0108 (B pin setup)  it is labeled  JHD521M7 12864AB ,

I have been trying to get work for about two weeks now , i have cross checked the wring more than 1001 ( I have Tomas Edison  beat on this one) and I have also learned how to labeling  all wires makes things easy , the GLCD work on my PIC so I know its good, however with the Arduiono there are no  pixels displayed, I could adjust the contrast and the back light is working fine , and I have ran  GLCDdiags  and i got this

Diag Loop: 3
Initializing GLCD
GLCD initialization Failed: RESET wait Timeout (status code: 2)

the pins are configured right, so  is there any one brave enough  to help me   

GLCD data sheet


This error means that the glcd library thinks the glcd is stuck in reset.
This is almost always do to a wiring error or wires not making proper connections.

Some additional information would be helpful in diagnosing the issues.

1) can you post the full diag output.
That will show additional information such as Arduino IDE revision, Arduino board type,
glcd library version, pin configuration, etc...

2) Were you having any issues with uploading or AutoReset?

3) What value Pot are you using and how do you have it wired up?
What is connected to each of the 3 pins on the pot?

4) can you show a clear photo of the front and back of the glcd including
the wires going to the 20 pin connector.

5) can you show a clear photo of the arduino board and the wires connected to it.

6) can you take a wider shot of the everything (arduino, wires, pot, and glcd)

That information will really help in trying to figure out what is happening.

--- bill


Thank you for responding

I have the pins set up  like this

22-   B 0   RS-   31
24-   B1   R/W-   33
26-   B2   E-   34
28 -    B3   CS1-   35
23-   B4   CS2-   32
25-   B5   RST-   30
27-   B6      
29-   B7      

#define glcdData0Pin        22
#define glcdData1Pin        24
#define glcdData2Pin        26
#define glcdData3Pin        28
#define glcdData4Pin        23
#define glcdData5Pin        25
#define glcdData6Pin        27
#define glcdData7Pin        29

#define glcdCSEL1           35
#define glcdCSEL2           33
#define glcdRW              32
#define glcdDI              30
#define glcdEN              34
#define glcdRES             31   

Diagnostic LOG

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-Manual
Pin Configuration:ks0108-Manual
GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:35(PIN_C2) CSEL2:33(PIN_C4)
RES:31(PIN_C6) RW:32(PIN_C5) DI:30(PIN_C7) EN:34(PIN_C3)
D0:22(PIN_A0) D1:24(PIN_A2) D2:26(PIN_A4) D3:28(PIN_A6)
D4:23(PIN_A1) D5:25(PIN_A3) D6:27(PIN_A5) D7:29(PIN_A7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(35,0x0, 33,0x1) CHIP1:(35,0x1, 33,0x0)
Data mode:
d0-d3:bit i/o
d4-d7:bit i/o
Diag Loop: 1
Initializing GLCD
GLCD initialization Failed: RESET wait Timeout (status code: 2)


The wiring


Feb 04, 2012, 03:38 am Last Edit: Feb 04, 2012, 03:48 am by bperrybap Reason: 1
From looking at the diag output, your schematic, and your
pin table (great information BTW).

I see a few things that look off.
It looks like there might be a misunderstanding of the Mega header.

The pins on the header are numbered/labeled like this:
Code: [Select]
22      23
24      25
26      27
28      29
30      31
32      33
34      35
36      37
38      39


52      53

Its hard to tell, but In the photo, it looks like you are using a 14 pin connector to plug into the
mega header and your connector is plugged in at the top
which is VCC and not pins 22 and 23.
From looking at your wiring table vs the diag output,
It looks like the RS/DI and RST/RESET wires are reversed.
and R/W and CS2 reversed.

If I look at your table it seems to indicate that you intended to wire it up like this:
Code: [Select]
22,data0        23,data4
24,data1        25,data5
26,data2        27,data6
28,data3        29,data7
30,RST/RESET    31,RS/DI
32,CS2          33,R/W
34,E            35,CS1

But the library was configured like this:
Code: [Select]
22,data0        23,data4
24,data1        25,data5
26,data2        27,data6
28,data3        29,data7
30,RS/DI        31,RST/RESET
32,R/W          33,CS2
34,E            35,CS1

Look at the diag output and you will see the pins that are configured
for each glcd function.
They don't seem to match up with the wiring table you showed.
The diag output is directly from the pins you assign in the config file file.

I think it should work once the header is aligned in the proper holes
(if it isn't already) and then when you fix the discrepancies between
R/W and CS2

One other thing that I noted from the diag output.
(see the part about "Data mode"? It indicates bit i/o vs byte i/o)
While you can use any pins you want for any of the glcd functions.
if you assign the data lines all to the same AVR port such each glcd pin
is connected to the matching AVR port bit, then the library will us 8 bit accesses
to write the port.
So rather than having to do 8 individual bit set/clear operations per byte it can
set all bits at once which will increase the performance of the library.
With Arduino and its goofy pin numbering scheme of naked constants it is impossible
to know which pins to use to make this happen without going through some contortions.

If you want to see which pins to use, to make this happen,
you have to look at the pins_arduino.h file.
On Arduino 1.0 for a mega, that file is in hardware/arduino/variants/mega/pins_arduino.h

Then you will want to pick the arduino pin # to assign the glcd data bits to match up with the
AVR port bits.

So if you wanted to use AVR port A
then you would use 22 - 29 for data0 to data7
(This is what the supplied ks0108 pin file does for mega)

So for your 14 pin connector, to get 8 bit i/o to the glcd you would use
this configuration instead:
Code: [Select]
22,data0        23,data1
24,data2        25,data3
26,data4        27,data5
28,data6        29,data7
30,RS/DI        31,RST/RESET
32,R/W          33,CS2
34,E            35,CS1

The data lines will need be assigned like this in order to get 8 bit i/o.
The control pins can be in any order, I just showed them
in the same order you used in your config file.

--- bill


you where right I had it on the 5Volt pin, I spent a long time trying resolve the problem, I just don't know why I did not see that, thank you, by the way great work on the GLCD library.


Its always the little stuff that gets in the way, at least that's what seems to happen to me.
A fresh set of eyes always helps.
Sorry you struggled with it for so long.

So is everything working ok now?

--- bill


Yes everything is working great ,I am exploring the library there is a lot you can do with this. 


Don't miss the included html documentation.
clicking on glcd/doc/GLCDref.htm will start it up.

--- bill


Hi guys,

I am also new to the arduino world. I am having a big trouble in compiling the GLCD code. I have put the GLCD library in the arduino libraries folder. But when I compile the GLCD example code I get the following compilation errors:

error: wiring.h: No such file or directory
In member function 'void ks0108::Init(boolean)':
ks0108.cpp:506: error: 'OUTPUT' was not declared in this scope
ks0108.cpp:506: error: 'pinMode' was not declared in this scope
ks0108.cpp:512: error: 'delay' was not declared in this scope

It is complaining about Init(boolean) function. Can someone please help me resolve this issue?


What Arduino IDE version are you using also

what version of the GLCD library are you using


I am having a big trouble in compiling the GLCD code.

I think you are using library ver2 please use the library ver3 made with colloboration with Michael by Bill (BPerry) or else you can just add:

Code: [Select]
#include "Arduino.h"
#include "Wiring.h"
"Real Men can Accomplish  Anything"

- skype : nishants5  
ਫ਼ਤੇਹ ਕਰੁਂ!

Go Up