Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

18F4520 LCD not working

Status
Not open for further replies.

camerart

Well-Known Member
Hi,
I am having difficulty getting an LCD to work with 18F4520 PIC, can anyone help please?
The 4 x20 LCD shows lines 1 and 3, 2 and 4 are dark.
Camerart.
 

Attachments

  • 18F4520 XTL 20MHz AZEL LCD BUTT-LOCATION 120516 1300.txt
    10.8 KB · Views: 305
hi,
Why are you adding CRLF to the LCD messages.?
Also you have declared the baselat and baselon as Single variables, how do you expect to get all those characters on one line of 20 characters.?
The message format is also incorrect.

Eric

'test ONLY
baselat = 52.123456
baselon = 1.123456
'############################################
Lcdcmdout LcdLine1Home
Lcdout "LCD TEST1 ", #baselat, " ", #baselon
Lcdcmdout LcdLine2Home
Lcdout "LCD TEST2 ", #baselat, " ", #baselon
Lcdcmdout LcdLine3Home
Lcdout "LCD TEST3 ", #baselat, " ", #baselon
Lcdcmdout LcdLine4Home
Lcdout "LCD TEST4 ", #baselat, " ", #baselon

'#############################################

EDIT:
This single quote in your original message effectively 'rem's out' the remainder of the message.
T " ', #ba
 

Attachments

  • A01.gif
    A01.gif
    6.7 KB · Views: 315
Last edited:
hi,
Why are you adding CRLF to the LCD messages.?
Also you have declared the baselat and baselon as Single variables, how do you expect to get all those characters on one line of 20 characters.?
The message format is also incorrect.

Eric

'test ONLY
baselat = 52.123456
baselon = 1.123456
'############################################
Lcdcmdout LcdLine1Home
Lcdout "LCD TEST1 ", #baselat, " ", #baselon
Lcdcmdout LcdLine2Home
Lcdout "LCD TEST2 ", #baselat, " ", #baselon
Lcdcmdout LcdLine3Home
Lcdout "LCD TEST3 ", #baselat, " ", #baselon
Lcdcmdout LcdLine4Home
Lcdout "LCD TEST4 ", #baselat, " ", #baselon

'#############################################

EDIT:
This single quote in your original message effectively 'rem's out' the remainder of the message.
T " ', #ba

Hi Eric,
I'm still playing with the program, perhaps I can leave that for now. I've simplified it and re posted it.
I'm concentrating on the LCD at the moment. I can get the it to work in the SIM, but not in the circuit.

Thanks, C.
 
I usually turn it until there is no bars then back until I can just see them.

If the screen hasn't initialized then only line one and line three will have solid bars..
Hi I,
It looks like it isn't initialising then, I can see 1 and 3, showing white (With nowt in)
C.
 
Next up is OSC settings.... You need to make sure its running correctly.... If this is your first run on real hardware did you turn off simulator delay shortning.... ( I see you did sorry!).... You're brownout is set very low and CCP1 is multiplexed with RC1.... What have you on RC1??
 
Hi Eric,
I'm still playing with the program, perhaps I can leave that for now. I've simplified it and re posted it.
I'm concentrating on the LCD at the moment. I can get the it to work in the SIM, but not in the circuit.

Thanks, C.

hi C,
Please don't modify a posted program, it makes my reply meaningless to later readers.

That LCD program header has worked OK for previous versions of the program.
Look at what changes you have made, also check your hardware changes.

E
 
Last edited:
Hi E and R,
The program with and without the LCD sections works ok, but with no LCD output.
Regarding the LCD. I have taken the LCD header and lines from working programs from other projects. I also tried a minimum program on a separate vero board circuit, and that LCD doesn't work either. (Different PICs and different LCD) The program with LCD work ok in simulation.
C.
 
I also tried a minimum program on a separate vero board
hi,
Please post a photo of you minimal PCB, front and back sides.

E
 
The program with LCD work ok in simulation.
I never got to grips with Vladimir's 4 bit interface... The only way I could get it working was to edit the ASM file...

You have rw and rs on portc but e on portd.... (strange) But I also noticed you have the RW connected to a pin and you've disabled the read busy.... That means portc.5 is in an undetermined state... You need to latch the portc.5 pin to ground.... LATC.5 = 0..
 
Never had a problem with Oshonsoft Basic code for either 4 or 8 bit, high/low byte.
I too don't understand why the OP has changed the bit assignment.?

E
 
Next up is OSC settings.... You need to make sure its running correctly.... If this is your first run on real hardware did you turn off simulator delay shortning.... ( I see you did sorry!).... You're brownout is set very low and CCP1 is multiplexed with RC1.... What have you on RC1??
Hi I,
Nothing connected to CCP1/RC1.
C.
 
Hi I and E,
My ears are burning:)
I was going to post photos of the circuits, but I got metal fatigue in the wires, so have been repairing them. Best not to keep moving wires and boards about!
The reason I changed the LCD bit assignment, was to line up better with my circuit (Attached)
I think the problem is with the Crystals on both circuits, not firing up. They were working before, so I'll have t0 investigate.
C.
 

Attachments

  • Circuit.jpg
    Circuit.jpg
    195.9 KB · Views: 291
hi C,
That's an image of your PCB layout, we need to see at least the components on the PCB.
I do not see any holes for 15pF caps around the 20mHz xtal holes.???

E
 
hi C,
That's an image of your PCB layout, we need to see at least the components on the PCB.
I do not see any holes for 15pF caps around the 20mHz xtal holes.???

E

Hi E and I,
I added the circuit board to illustrate why I changed the LCD settings. It was to line the wires up on the side where the LCD screen is.
I've just done a test, changing the 20MHz XTL to INT OSC 8MHz. I added a toggle LED in a LOOP after the LCD header. The LED flashed only when LCDINIT was commented out.
Well spotted regarding the holes for the 15pF Caps on the main circuit, I forgot to add them and soldered them to the legs of the XTAL. I also was reminded that I used 22pF Caps. On the separate circuit I used the correct 15pF Caps. Both were working until lately, in fact I've been using the main circuit on my test bed for the past year.
So I need to sort out a few things, including buy some 15pF Caps, and address Ian's suggestion around the OSC settings.
C.
 
Hi,
After reading up about LCDs, I grounded D0-D3 and stopped using LCD R/W and now I have "LCD TEST" on all four lines.
Thanks, Camerart.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top