The Grafic LCD shows nothing

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

The Grafic LCD shows nothing

Post by CS » Thu Nov 02, 2006 10:16 pm

Hi all,

I'm again! The following code compiles correct, but shows nothing on my hardware.

Code: Select all

Device = 18F452
Clock = 20

Include "GLCD.bas"
Include "FixedFont.bas"
Include "Arial.bas"
Include "Garamond.bas"
Include "Tahoma.bas"
Include "Verdana.bas"
Include "Times.bas"

#option GLCD_RS = PORTB.4
#option GLCD_EN = PORTB.6
#option GLCD_RW = PORTB.5
#option GLCD_CS1 = PORTB.2
#option GLCD_CS2 = PORTB.3

GLCD.Cls	
GLCD.SetFont(Fixed)
GLCD.WriteAt(4,2,"System Font")
GLCD.SetFont(ArialBold)
GLCD.WriteAt(4,10,"Arial Font")
GLCD.SetFont(GaramondBold)
GLCD.WriteAt(4,20,"Garamond Font")
GLCD.SetFont(TahomaBold)
GLCD.WriteAt(4,30,"Tahoma Font")
GLCD.SetFont(VerdanaBold)
GLCD.WriteAt(4,40,"Verdana Font")
GLCD.SetFont(TimesBold)
GLCD.WriteAt(4,50,"Times New Roman")
After I checked my hardware, I found that my display has one more wire called RST !?

My hardware looks like the following:

D0 ... D7 > RD0 - RD7
RST > RB7
E > RB6
R/W > RB5
RS > RB4
CS2 > RB3
CS1 > RB2

What's now wrong ?????????? What should I do with PORTB.7 ?????

Best reguards and good night

CS

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Thu Nov 02, 2006 10:23 pm

The solution should be simple - the display RST should be tied to 5V and the #option statements should be moved before the Include "GLCD.bas" line. The last point is important, since the code in the libraries is altered according to the option settings that have already been declared.

Regards,

Steven

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Nov 03, 2006 2:06 pm

Hi Steve,

back again on my problem from last night I have changed the code like you sayed. (It seems that the RST is uninteresting) The result is very interesting!

First of all I had to PULL UP all the used PortPins!

And now the result:

It depends on whatever (I don't know) sometime (At this time once) I get a good result but mostly I get woozy things. Also sometimes only the right half of the display works sensible. The left half don't work.

Very interessting is the following thing: When I change the osszilator to 8 MHz or 10 MHz without changeing the code I can see, how the display draws all the letters but at the end the display is like I expected and like I programmed the PIC. When I returnes the changes everything is woozy again.

Also interesting is the thing, that all pixels are black at start!

What's now wrong?

CS

NavMicroSystems
Posts: 4
Joined: Thu Nov 02, 2006 6:39 pm
Location: Germany

Post by NavMicroSystems » Fri Nov 03, 2006 4:51 pm

Could you try the following and let us know what the result was?

Code: Select all

#option GLCD_CS1        = PORTB.3      // chip select
#option GLCD_CS2        = PORTB.2      // chip select
#option GLCD_INVERT_CS  = true         // invert CS lines
#option GLCD_INIT_DELAY = 200          // initialisation delay (ms)

Very interessting is the following thing: When I change the osszilator to 8 MHz or 10 MHz without changeing the code I can see, how the display draws all the letters but at the end the display is like I expected and like I programmed the PIC. When I returnes the changes everything is woozy again.
Am I right in understanding it works just fine at a lower clock speed?
Ralph

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Fri Nov 03, 2006 5:20 pm

I've just been having a look at your code and in the meantime NavMicroSystems has suggested the same as I was going to. If this works, it's not a fault of the compiler, but simply a result of the fact that KS0108 displays have various arrangements for the CS lines - some need inverting as suggested.

In addition, the pullups should not be needed - try removing them once you have made the above modification. Check that you are not having to do this only to tie the RST high.

Regards,

Steven

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Nov 03, 2006 6:25 pm

Hi,

the code looks like the following:

Code: Select all


Device = 18F452
Clock = 20

#option GLCD_RS = PORTB.4
#option GLCD_EN = PORTB.6
#option GLCD_RW = PORTB.5
#option GLCD_CS1 = PORTB.3
#option GLCD_CS2 = PORTB.2
#option GLCD_INVERT_CS  = true
#option GLCD_INIT_DELAY = 200

Include "GLCD.bas"
Include "FixedFont.bas"
Include "Arial.bas"
Include "Garamond.bas"
Include "Tahoma.bas"
Include "Verdana.bas"
Include "Times.bas"

Dim RST As PORTB.7

High(RST)

GLCD.Cls	
GLCD.SetFont(Fixed)
GLCD.WriteAt(4,2,"System Font")
GLCD.SetFont(ArialBold)
GLCD.WriteAt(4,10,"Arial Font")
GLCD.SetFont(GaramondBold)
GLCD.WriteAt(4,20,"Garamond Font")
GLCD.SetFont(TahomaBold)
GLCD.WriteAt(4,30,"Tahoma Font")
GLCD.SetFont(VerdanaBold)
GLCD.WriteAt(4,40,"Verdana Font")
GLCD.SetFont(TimesBold)
GLCD.WriteAt(4,50,"Times New Roman")

It works fine with one exception. After power on I have to reset the chip, then the display shows everthing that I want (at this time)! :D

I also removed the pullups and everything is ok! I'm on the way to say everything is perfect. But what happens with the reset?

Best wishes

CS

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Fri Nov 03, 2006 6:41 pm

CS,

It's good to hear that you are much closer now. The reset issue is caused I think by the fact that your RST pin on the display is connected to a PIC port pin, rather than tied high in hardware. Are you using an EasyPIC development board like me?

You have set the RST pin high in your code, but this will happen after the display has been initialised by the GLCD/KS0108 library - the code for this is inserted at the Include position. I do not think there is a way of doing it before, without altering the KS0108 library itself.

I have made a modification to the KS0108 library that allows the RST pin to be included with a #option and then sets the pin high automatically. I've emailed Dave Barker about this, and will let you know if he adds this functionality - otherwise, I'll email you a version which you could include in your user library folder. This hopefully will overcome the problem.

Regards,

Steven

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Nov 03, 2006 7:51 pm

Hi Steve,

yes I have some EasyPic-DevBoards from mikroElektronika for testing. But the problem appears on all EasyPic Boards so I thought, that is an Compiler Error. If I have the time, I'll build the schematic on a breadboard to see, whats happening.

It would be nice, to have the altered GLCD modul.

Did it the job perfect for you?

At this time I trie to convert a mE project with some difficult parts to Swordfish, then I'll see whether or not the display will do his work (I think for this project Swordfish will be the better choice). That will also be a help for decision between Swordfish and mE.

Thanks in advance

CS

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Fri Nov 03, 2006 7:55 pm

CS,

If you PM me with your email address, I'll send you the modified library to try.

Regards,

Steven

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Nov 03, 2006 9:44 pm

Steven,

you have a PM!

Best wishes

CS

Post Reply