LCD problem with 16F628


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Question LCD problem with 16F628

    Good morning to everybody,

    I have a problem with my code.LCD--->16F628

    Please check my code!!!
    Thnks


    ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
    '
    ' LCD should be connected as follows:
    ' LCD PIC
    ' DB4 PortA.0
    ' DB5 PortA.1
    ' DB6 PortA.2
    ' DB7 PortA.3
    ' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
    ' E PortB.3
    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (or ground)
    ' DB0-3 No connect
    @ DEVICE pic16F628, INTRC_OSC_NOCLKOUT ' system clock options
    @ DEVICE pic16F628, WDT_ON ' watchdog timer
    @ DEVICE pic16F628, PWRT_ON ' power-on timer
    @ DEVICE pic16F628, MCLR_OFF ' master clear options (internal)
    @ DEVICE pic16F628, BOD_ON ' brown-out detect
    @ DEVICE pic16F628, LVP_OFF ' low-voltage programming
    @ DEVICE pic16F628, CPD_OFF ' data memory code Protect
    @ DEVICE pic16F628, PROTECT_OFF ' program code protection


    Define LCD_BITS 4 ' 4-bit interface
    Define LCD_LINES 2 ' 2 line LCD

    ' LCD should be connected as follows:
    ' LCD PIC
    ' DB4 PortA.0
    ' DB5 PortA.1
    ' DB6 PortA.2
    ' DB7 PortA.3
    Define LCD_DREG PORTA
    Define LCD_DBIT 0

    ' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
    Define LCD_RSREG PORTA
    Define LCD_RSBIT 4

    ' E PortB.3
    Define LCD_EREG PORTB
    Define LCD_EBIT 3

    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (wire wiper to Vo, adjust for contrast)
    ' DB0-3 No connect

    Define LCD_COMMANDUS 2000 ' Adjust for slower LCD modules
    Define LCD_DATAUS 50

    INCLUDE "MODEDEFS.BAS"
    INTCON = 0 ' Disable interrupts
    CMCON = 7
    Pause 500 ' Wait for LCD to startup

    loop: Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "By:Geronikolos" ' Display Hello
    Pause 500 ' Wait .5 second

    Lcdout $fe,$c0,"World" ' Clear LCD screen
    Pause 500 ' Wait .5 second

    Lcdout $fe,$c0,"Hello" ' Clear LCD screen
    Pause 500 ' Wait .5 second

    Goto loop ' Do it forever

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You might want to try these two things...

    1. Ground D0-D3 on the LCD

    Don't leave those lines not connected and floating - it's bad practice.

    2. Increase the inital Pause 500 to Pause 1000

    Pause 500 may be insufficient for your LCD to initialise at power-on.

    Why don't you want to use A.5 for E-Bit? That way the whole of PORTB is free for your applications use. If you used A.6 for the RS Bit, you wouldn't need that Resistor either.

    Additionally, although this has nothing to do with the LCD... INTCON = 0 is unnescessary as Interrupts are disabled by default.

  3. #3
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    Thanks for your advice but nothing.I ground D0-D3 on the LCD and I change the inital Pause to 1000 and 1500.

    I saw on my lcd all first line with black blocks.

    Please advice

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    1. Check the SPELLING of your LCD Defines... they must be EXACT because the compiler will not flag errors if have made a mistake there.

    2. Check that you have not mistakenly swapped your E or RS bits and connected them the wrong way around...

    3. Turn down your contrast... if it's too high then you might be swamping any displayed data with black blocks.

    4. Finally, double-check your hardware connections against your DEFINES.

    There are no problems or issues connecting LCDs to a 16F628 on internal oscillator with internal MCLR therefore it must be something in your connection...

  5. #5
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Question

    The compiler is OK.No errors.

    May my programmer cause the problem?
    Because the circuit and the program was working in the past.

    Thanks

  6. #6
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    I check my circuit and it seems ok.
    That is the diargam of it.

    Please have a look.
    Attached Images Attached Images  

  7. #7
    Join Date
    Aug 2016
    Posts
    22


    Did you find this post helpful? Yes | No

    Default Re: LCD problem with 16F628

    Please see below thread discussion. This may help you.
    https://www.ccsinfo.com/forum/viewtopic.php?t=42284

Similar Threads

  1. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. Gps with 16f628
    By dragons_fire in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th June 2006, 03:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts