PDA

View Full Version : LCDOUT with 16f684



rastan
- 19th November 2004, 14:10
Hi, got a problem with my LCD display. it doesnt work and i think the reason why is because i need to connect the data line D4-D7 to pins RA0-RA3. the problem is that RA3 is either MCLRE or a digital INPUT.

therefore i cannot have an output on that pin and i cant see a way to change the data out pins on the pic to anything but port a pins 0 to 3.

also, this is the first time ive tried to use an LCD screen so what should it look like when it works. obviously there is no data going to the module, but i would have thought there would be some indication that the power is on, like a flash of the screen or something, but there was nothing. nothing changed.

im using a powertip PC2004A - a 20 charater, 4 line module.
pic 16f684 with internal rc no clock out, mclre disabled.
connected it up like in the pbp manual. except the data lines.


thanks guys
phil

Ingvar
- 19th November 2004, 16:53
Hi Phil,

If you're not planning on using the low half of PortC you could use that instead. You change it with a DEFINE, it's all in the manual. If you intended to use any of the hardwarefeatures on portC(low half) you're in trouble. The only option left is to change the assemblercode that makes up the instruction LCDOUT(and LCDIN if used). It can be done if you have the assemblerskills needed. You could perhaps use a different Pic, it all depends on what you want to do.

Never used a powertip, can't help you with that.

/Ingvar

rastan
- 20th November 2004, 12:23
yeah thanks. cant believed i missed that. ill try it

cheers
phil

rastan
- 21st November 2004, 20:21
well its still not working, ive tested the circuit with a 16f628A on proteus and it works, but i cant simulate a 684 and i dont have any other chips till they come in the post.

im a bit worried about the actual lcd module, because there seems to be no life in it what so ever apart from the led backlight.

is there any way to test it? like make all of the lcd's bits turn on so i can see if its not knackered?

thanks

phil

rastan
- 21st November 2004, 20:25
by the way, this is the code for a 16f684

;LCD test Program

; Set LCD Data port
DEFINE LCD_DREG PORTC
; Set starting Data BIT (0 OR 4) IF 4-BIT bus
DEFINE LCD_DBIT 4
; Set LCD Register Select port
DEFINE LCD_RSREG PORTC
; Set LCD Register Select BIT
DEFINE LCD_RSBIT 0
; Set LCD Enable port
DEFINE LCD_EREG PORTC
; Set LCD Enable BIT
DEFINE LCD_EBIT 1
; Set LCD bus size (4 OR 8 bits)
DEFINE LCD_BITS 4
; Set number of lines ON LCD
DEFINE LCD_LINES 4
;
DEFINE LCD_COMMANDUS 2000
; Set Data delay time in us
DEFINE LCD_DATAUS 50


TRISA = 0
TRISC = 0

cmcon0 = 7
ansel = 0


loop:
Pause 1500
LCDOut $FE,1,"Hello" ; Clear display AND show “Hello”
LCDOut $FE,$C0,"World" ; Jump TO second line AND show “World”
GoTo loop

rastan
- 21st November 2004, 20:28
sorry, one more thing, ive tested the pic with a scope and there are some sort of bits/commands coming out, so assuming the codes correct its working.

Also, i put a current meter in the circuit and it only showed 1.62mA and the lcds datasheet that it normally takes about 2.5mA so its not getting powered properly.

thats it. promise.

phil

mister_e
- 21st November 2004, 22:18
be sure your r/w pin (pin 5) on LCD is ground. Is when you're increase voltage on Vo (pin 3, kind of contrast) you see some black square block?

by the way PORTC is only 6 bits.... so you must you this define


; Set starting Data BIT (0 OR 4) IF 4-BIT bus
DEFINE LCD_DBIT 2 ;instead of 4

but not sure if it's gonna work

May use
DEFINE LCD_DBIT 0



do you use internal or external clock. In case you use internal clock you have to define OSCCON for proper clock mode.... factory is 32khz...really slow

datasheet p31 (pdf)

OSCCON=$60 ;set to internal 4MHZ clock

that will work now!!!

rastan
- 21st November 2004, 22:34
ok thanks steve, r/w pin is on ground, modified code and circuit to give

;LCD test Program

; Set LCD Data port
DEFINE LCD_DREG PORTC
; Set starting Data BIT (0 OR 4) IF 4-BIT bus
DEFINE LCD_DBIT 0
; Set LCD Register Select port
DEFINE LCD_RSREG PORTC
; Set LCD Register Select BIT
DEFINE LCD_RSBIT 4
; Set LCD Enable port
DEFINE LCD_EREG PORTC
; Set LCD Enable BIT
DEFINE LCD_EBIT 5
; Set LCD bus size (4 OR 8 bits)
DEFINE LCD_BITS 4
; Set number of lines ON LCD
DEFINE LCD_LINES 4
;
DEFINE LCD_COMMANDUS 2000
; Set Data delay time in us
DEFINE LCD_DATAUS 50


TRISA = 0
TRISC = 0

cmcon0 = 7
ansel = 0


loop:
Pause 1500
LCDOut $FE,1,"Hello" ; Clear display AND show “Hello”
LCDOut $FE,$C0,"World" ; Jump TO second line AND show “World”
GoTo loop


also, i tested the contrast and got nothing. increased it to 9v. zilch

do you think it is a knackered module???

cheers

mister_e
- 21st November 2004, 22:40
more sure it's because...

do you use internal or external clock. In case you use internal clock you have to define OSCCON for proper clock mode.... factory is 32khz...really slow

datasheet p31 (pdf)

OSCCON=$60 ;set to internal 4MHZ clock

maybe also an defect LCD... everything is possible.

rastan
- 21st November 2004, 22:49
thanks mister_e, never thought of that, intrestingly though i put an extra bit of code in to flash an led for a split second and tested that with both the oscon in the code and without it. the led flashed at the same rate. are you sure that the default is 32kHz?

as for the lcd working, it still doesnt so i think i might have to send it back.

if anyones got anymore ideas then please say so.

thanks everyone
phil

mister_e
- 21st November 2004, 22:54
what about if you're connecting all led to PORTC pins.

and do

OSCCON=$60

start:
PORTC=255
pause 500
PORTC=0
pause 500
goto start.


are all the led flash???


i'm sure you take care of connections of LCD but it happen to me one time to use BACKLITE pins instead of DATA pins... Are the other data pin left open or tied to ground. Some need to be connected to ground. Also try bigger delay at the beginning. Let's say 5 seconds.


regards

rastan
- 21st November 2004, 23:00
yup all the leds flash.
double checked the led's led pins. ok.
good idea with connecting d0-d3 to ground, still the same. doesnt work.

phil

rastan
- 21st November 2004, 23:01
lcd's led. sorry

mister_e
- 21st November 2004, 23:08
WEIRD... look to be defect LCD.

what about if you use these line after PAUSE 2000 at the begining

;reinitialize Lcd before write on
lcdout $fe,$28 ;lcd mode 4 bits,5x7, 2 lines
lcdout $fe,$0c ;lcd on
lcdout $fe,1 ;clear lcd


but you put 9 volt to Vo pin... not sure is a good idea...


can you add 10uF tantalum (47uF electrolytic) and a 0,1uF an the supply line close to the LCD ???

rastan
- 21st November 2004, 23:12
nope. its gotta be a dead lcd.

ill give it one more try when i get some 16f628A chips, and if that doesnt work then ill send it back.

thanks mister_e

phil

mister_e
- 21st November 2004, 23:13
good idea ! let us know what's happenning with 16F628. But i don't think it will be different.

regards

rastan
- 24th November 2004, 21:31
Well just to let you know, i emailed the seller and it turns out that the only problem after all that was the voltage applied to the contrast pin Vop (or Vo in many cases). According to the appropriate powertip 2004A datasheet it states that this should be 4.2 - 4.8 volts. when i applied this i could not see it.
when i applied 0.5 volts to it, bingo! it works fine.

thanks a lot.
phil

mister_e
- 25th November 2004, 04:32
Usually for experimenting we place an trim pot on this pin... this is why i asked you what about if you vary the voltage on contrast pin...

anyway, great to know everything's working good for you now!!!|

regards