1. 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.
    Dismiss Notice

18F4520 LCD not working

Discussion in 'Oshonsoft' started by camerart, May 12, 2016.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

    Attached Files:

  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     

    Attached Files:

    • A01.gif
      A01.gif
      File size:
      6.7 KB
      Views:
      96
    Last edited: May 12, 2016
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    What contrast pot have you used??? Seems as if its either on 0 or 5v..
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.

    10K I have set it for best, I think.
    C
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    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..
     
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    It looks like it isn't initialising then, I can see 1 and 3, showing white (With nowt in)
    C.
     
  9. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    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??
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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: May 12, 2016
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Please post a photo of you minimal PCB, front and back sides.

    E
     
  13. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,145
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    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..
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    Hi I,
    Nothing connected to CCP1/RC1.
    C.
     
  16. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

    Attached Files:

  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,174
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     
  18. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,304
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

Share This Page