Need help with optrex LCD


Closed Thread
Results 1 to 4 of 4
  1. #1
    mk432's Avatar
    mk432 Guest

    Default Need help with optrex LCD

    I am having a horrible time trying to get an optrex LCD (DMC 16433) to spit out anything. I have a PIC 18F458 that works fine on a LAB-X1 LCD board, yet when I try to hook it up with a 4 line optrex, I get two solid bars on the first and third line. I think I have it set right, I just can't figure out what is wrong about it.

    DEFINE LCD_LINES 4
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE OSC 40 '40 MHz clock


    ADCON1 = 7 ' Set PORTA and PORTE to digital
    'Low PORTE.2 ' LCD R/W line low (W)
    TRISD = 0 ' Set PORTD (LEDs) to all output
    PORTD = 0 ' All LEDs off
    INTCON2.7 = 0 ' Enable internal pullups on PORTB
    TRISB=%11110000 ' =1 makes B port input and =0 makes B port output
    PORTB = 0 ' PORTB lines low to read buttons

    Pause 100 ' Wait for LCD to startup '
    LCDOut $fe, 1 ' Clear screen

    loop:
    Pause 500
    LCDOut $fe, $80, "Hello"
    LCDOut $fe, $c0, "World"
    Pause 500
    LCDOut $fe, 1 ' Clear screen
    GoTo loop ' Do it forever
    End



    If you have any thoughts I would love to hear them.

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


    Did you find this post helpful? Yes | No

    Default

    I have two thoughts initially...

    1. That initial Pause 100 is far too short.... increase it to Pause 2000 at first, you can then pare it back to Pause 1000 if it does the trick.

    2. Don't tamper with the LCD Port pins manually, leave it to PICBasic. You've got the data pins on PortD, you then manually set the WHOLE of PortD to zero with...

    PORTD = 0 ' All LEDs off

    Don't do it. Set the non-LCD pins individually and don't play with the LCD pins unless you know what you're doing... ie...

    PortD.0=0
    PortD.1=0 etc etc.

    Better still... define those pins at the start of your program... eg...

    LEDA var PortD.0
    LEDB var PortD.1 etc etc

    then within your program you can just refer to the aliases...

    Low LEDA
    Low LEDB and so forth.

  3. #3
    mk432's Avatar
    mk432 Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Thank you Melanie. I got it to work, check it out:

    DEFINE LCD_LINES 4
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE OSC 4 '10 MHz clock

    Pause 5000
    ADCON1 = 7 ' Set PORTA and PORTE to digital
    ' Low PORTE.2 ' LCD R/W line low (W)
    TRISD = 0 ' Set PORTD (LEDs) to all output
    ' PORTD = 0 ' All LEDs off
    INTCON2.7 = 0 ' Enable internal pullups on PORTB
    TRISB=%11110000 ' =1 makes B port input and =0 makes B port output
    PORTB = 0 ' PORTB lines low to read buttons



    loop: LCDOut $fe, 1 ' Clear screen
    Pause 1000 ' Wait .5 second

    LCDOut $fe, $80, "Line 1" ' Display "Line 1"
    Pause 1000

    LCDOut $fe, $c0, "Line 2" ' Move to line 2 and display "Line 2"
    Pause 1000

    LCDOut $fe, $94, "Line 3" ' Move to line 3 and display "Line 3"

    Pause 1000

    LCDOut $fe, $D4, "Line 4" ' Move to line 4 and display "Line 4"
    Pause 1000 ' Wait .5 second
    LCDOut $fe, 1

    GoTo loop ' Do it forever
    End




    I had to reduce the speed from 40Mhz to 4Mhz, add a 5 second boot pause, and then a 1 second pause after each LCDOUT statement. It's awful but it works, I guess the PIC18F is too fast for the HD44780 chip set.

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


    Did you find this post helpful? Yes | No

    Default

    I've known Optrex were slow, but that's just plain ridicculous. Are you sure you told PICBasic you were working at 40MHz? I see that DEFINE OSC 40 statement, you sure you didn't miss-spell it?

    What happens if you try this now...

    loop:
    LCDOut $FE, 1
    Pause 1000
    LCDOut "Line 1",$FE, $C0, "Line 2",$FE, $94, "Line 3",$FE, $D4, "Line 4"
    Pause 1000
    GoTo loop

    You should get all the text displaying in one hit with a 1 second pause, and repeat. You need one puase somewhere to allow time to read what you've displayed before it gets erased again.

    Amother point... have you otherwise accounted for grounding the R/W line? You've rem'd it out in your last posting, I trust you've not left it floating.

    There's a couple of other defines for the LCD...

    Define LCD_COMMANDUS 2000
    Define LCD_DATAUS 50

    You can try increasing those... (say double them as a starting point). You should be able to use your LCD with the PIC running at 40MHz without problems.

    Melanie

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. 16F84A and Optrex LCD
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th October 2005, 16:08

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