Graphic LCD Code

beny1949

Senior Member
after getting over the previous problem i was having with not knowing the power requirements of my new graphic LCD, I have run into another slight hixk, and i was wondering if anyone would be able to offer any advice.

Firstly the data sheet for the LCD can be found at www.ben-howes.co.uk/GraphicLCD.pdf

I have written the followinf code to try set up the display, and with any luck make some of the screen striped.

Code:
 '' Pin Configurations

' EN 1 is on portc pin 2
' EN 2 is on portc pin 5
' R/W is on portc pin1
' A0 is on portc pin0

'outpins= d0-7

Symbol DisData = b0


INIT:
	pause 1
	high portc 6
	pauseus 1
	low portc 6
	pauseus 1
	high portc 6
	pins = %10101110 ^ $80 ' Display: OFF
	gosub Both
	pins = %11000000  ^ $80 ' Start display on line 1
	gosub Both
	pins = %10100100 ^ $80  ' Static Drive: OFF
	gosub Both
	pins = 0 ' Start At Column 0
	gosub Both
	pins = %10111011 ^ $80  ' page 1
	gosub Both
	pins = %10101001 ^ $80  ' 1/32 duty
	gosub Both
	pins = %10100000 ^ $80  ' ADC: rightward output
	gosub Both
	pins = %11101110 ^ $80  ' Read Modify Write: off
	gosub Both
	pins = %10101111 ^ $80  ' Display: ON!
	gosub Both
	
Main:
	high portc 0
	pins = %10101010 ^ $80 
	for b10 = 1 to 60
		gosub Both
		pauseus 10
	next b10
	
	End
	
LeftScreen:

	high portc 2
	pauseus 1
	low portc 2
	return
	pauseus 1
RightScreen:
	high portc 5
	pauseus 1
	low portc 5
	pauseus 1
	return
Both:
	high portc 2
	high portc 5
	pauseus 1
	low portc 2
	low portc 5
	pauseus 1
	return
Nothing appears to happen on the screen. I am using a 40x1 (A.0 firmware) hence the ^ $80 on the pins assigment.

As for initialising the screen, i have followed the flow chart in the data sheet to the letter!

can anybody suggest where im going wrong with it?

Ben
 
Last edited:

BeanieBots

Moderator
I'll take your word for it that the code is doing what is should.
What about that -5v from your previous thread?
At a guess, it is to control the contrast.
Can you get the display to darken by adjusting the contrast?
It may well be that you are driving it correctly but simply can't see that it has worked.
 

hippy

Technical Support
Staff member
after getting over the previous problem i was having with not knowing the power requirements of my new graphic LCD
That's the eBay cheapo with an unknown Vlcd ? Go on ... what was the answer ?


I am using a 40x1 (A.0 firmware) hence the ^ $80 on the pins assigment.
That could be the problem. This was a 'hack' for fixing an early version of the compiler and the compiler now automatically includes the hack behind the scenes. Take the "^ $80" out and see if that improves things.

If the screen is still completely blank, the Vlcd issue may not be completely solved yet. I haven't looked at your code, but will do if removing the "^ $80" and twiddling the contrast pot doesn't get you anywhere. Unless you've been sold a lemon, it should be possible to get it working.
 

beny1949

Senior Member
I am able to control the contrast, i have a 10k pot between 0 and -5 volts, with the wiper to the VLCD pin. all seems to be ok there!

there must be something wrong with my code i am guessing!


Ben
 

hippy

Technical Support
Staff member
@ Ben : Just spotted your other post, so my fault for missing it :)
 

beny1949

Senior Member
I have had a go without the ^ $80 which with a little test, gives the correct output on the pins, so we know that that is not the problem!

so now the screen is all the same, so its either all on or off, not sure where the correct place for the contrast pot is.
 

beny1949

Senior Member
prehaps its time for me to admit i may be relising i just might have a dud!

will have to have a go with the other LCD tomorrow....

joy!

Thanks very much
 

andrew_qld

Senior Member
Most of the problems I have had with LCD's have been related to:

(1) Not enough volts (LCD's require a good +5V whereas I usually rin the picaxe from 3 x 1.5V AA cells= 4.5 V) or,

(2) The contrast pot on the LCD is either faulty, badly adjusted, dry jointed or just won't reach the desired setting.

Does the LCD do ANYTHING when you power it up? Can you see a faint flash of dark contrast?
 

beny1949

Senior Member
i am using a very well regulated expensive bench supply that i got my hands on a few months ago to provide the +/-5 volts, so i have no doubt that the power is a problem in this situation...

the contrast pot i am using would appear to be fine, as i can adjust the contrast between all on and completly off. a reset of the picaxe causes a slight flicker, but other than that, all of the pixels are on all of the time!

Ben
 

andrew_qld

Senior Member
Sounds as though the contrast and power supply are all ok then. Although contrast should be adjusted for mid level and not "all on".

If all the pixels flicker when you reset the picaxe then it sounds like the LCD is OK.

If all the elements are on all the time then it sounds like either a contrast adjustment problem or a code problem. I haven't had any experience with graphic LCD's, only the alpha-numeric ones.
 

hippy

Technical Support
Staff member
Double check your wiring as it's easy to miscount pins or get wires crossed over. Getting D0-D7 crossed over to I/O7-I/O0 is not unknown. Check you haven't used the wrong PICAXE ports entirely, it can happen.

Do you need a 'LET DIRSC=' command to initialise the port direction ? I also recall someone saying that they were seeing random inititialisation of Port C, so it may be worthwhile starting with a 'LET PINSC=$00', or explicit "LOW PORTC" for all the pins used to start with.

The datasheet doesn't say if E1 and E2 can be pulsed at the same time. I'd have expected they could, but it may be worthwhile strobing each sequentially rather than simultaneously, or simply not strobing one or the other until you get something showing on the screen.

You may also need to extend some of your pause times. 1uS may be a little too low, especially between sending the initialisation bytes. Traditional HD44780 text drivers can require 40mS or so during initialisation. 40uS between sending data bytes.

Definitely increase the pause times ( PAUSE 10 ), before, during and after the reset pulse in your initialisation. Pause times can be reduced once everything is working. Staring with a very long pause ( PAUSE 1000 ) after setting all Port C low will give the LCD time to have powered-up and settled down.

What have you done with the R/W line ? This could be put under program control, but would be best connected to 0V to start with. If it's pulled-up to +V then you may have risked damaging the PICAXE or LCD. You can test the PICAXE I/O with a short test program which flashes each pin at a time and watch the pin with a LED or DMM.

Finally, replace your "END" with "WaitForever: GOTO WaitForever".
 

nbw

Senior Member
I'd be keen to try my 128x64 off my 40X (the oldie!)... I think from memory that runs at 4Mhz, but maybe upping to 8Mhz might help it paint the display quick-smart. At a push I suppose I could add a small i2C eeprom to store character layouts etc - depends tho on how much code I use from the 2048 bytes available I guess.
 

nbw

Senior Member
Damn, hit post before I meant to. Am I correct in saying you need 8 x data lines + 2 chip selects = 10 output ports spare to run the GLCD from a picaxe? thanks all. I've been away a while (had another kid. actually, my wife did but you get the idea)
 

nbw

Senior Member
13 pins isn't actually too bad. A 8Mhz 40X should be able to handle that. Unlike other GLCDs I've been reading about, My TopWay LM6038D seems to have a voltage in range of just 2.8 - 3.3V, rather than the 5V. Odd. Mental note for me not to hook it directly to the 5V picaxe power supply rail!
 

nbw

Senior Member
Hmmm. Also odd that my TopWay GLCD has only one Chip Select not two like some of the others around. Maybe I can drive it using just 12 instead of 13 ports.......
 
Top