LCD wont work :(


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Location
    Upstate New York
    Posts
    8


    Did you find this post helpful? Yes | No

    Post Oilmex board LCD for Comparason

    I recently got my PIC-MT-USB up and running, with help from this forum. I got the switches to work and the lights to blink. The LCD was the next headache. I was hoping that your thread may give me some ideas. But I managed to get it to work with the help from an article: http://www.epemag.wimborne.co.uk/lcd1.pdf
    I am an old TTL guy, so the wiring diagram made lots of sense to me, and finally got it working. My code is attached with comments. It may offer some ideas. Hope it helps.
    Comments about my code are welcome from the community. I am a nophyte.

    '************************************************* ***************
    '* Name : OILMEX TEST *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 8/24/2009 *
    '* Version : 1.0 *
    '* Notes : FOR THIS TO WORK ON THE OLMEX BOARD *
    '* : the INC file had to be changed to *
    '* : change the config to HS from XT *
    '* : *
    '************************************************* ***************
    '************************************************* **************
    '* This block of code sets up switches to drive LEDs

    LED1 VAR PORTB.2
    LED2 VAR PORTB.1
    SWITCH1 VAR PORTB.4
    SWITCH2 VAR PORTB.5

    TRISB = %11111001 'sets bit 1, 2 to output. all else to input

    LOW LED1 'inatilized leds
    LOW LED2 'LED initalizain probabbly not needed

    '********** END PUSH BUTTON / LED CODE*********************

    '************* LCD DRIVER TEST CODE **********************
    '****** PINS BASED ON SCHEMATIC ***************************
    '* LCD Connections
    '* _RS PORTD0 -DATA when LOW, Commands when HIGH
    '* .R/W PORTD1 - LOW to WRITE Date, HIGH to READ data from LCD
    '* E PORTD2 - Data transferred on Transition High to Low
    '* Light PORTD3
    '* DB4 PORTD4
    '* DB5 PORTD5
    '* DB6 PORTD6
    '* DB7 PORTD7

    '**************


    define LCD_DREG PORTD 'Display connected to PORTD
    DEFINE LCD_DBIT 4 'Data Starting Bit (0, or 4)
    'When set to 0, Backlight Display Blinks, no Data
    DEFINE LCD_RSREG PORTD 'Reset register is on PortD
    DEFINE LCD_RSBIT 0 'Reset Bit is D0
    Define LCD_EREG PORTD 'Enable on PORTD
    DEFINE LCD_EBIT 2 'enable bit D2
    '*********** These LCD DEFINES not needed (presumably) *******
    'DEFINE RW_REG PORTD
    'DEFINE LCD_RWBIT 1
    'DEFINE LCD_BITS 4
    DEFINE OSC 20 'The display was jumpp, This took care of it
    'DEFINE LCD_COMMANDUS 2000
    'DEFINE LCD_DATAUS 50 'data delay in µs'
    'Define LOIADER_USED 1
    'define NO_CLRWDT 1
    '*************** End of UNUSED LCD DEFINES ******************
    TRISD = %00001111 'Set D4-8 as output. D0-4 as Input

    low PORTD.1 'Set NOT R/W to LOW (Write Data TO LCD)
    High PORTD.3 'Turn on Back LIght (Tested - Works)



    Pause 500 ' Wait for LCD to startup


    mainloop:
    Lcdout $fe, 1 ' Clear LCD screen
    PAUSE 500
    Lcdout "Hello" ' Display Hello
    Pause 500 ' Wait .5 second

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

    '************* PUSHBUTTON / LET TEST RUTINE *************
    IF SWITCH1 = 0 Then 'NOTE Button Goes to 0 When pressed
    HIGH LED1
    else
    low LED1

    ENDif

    IF SWITCH2 = 0 then
    HIGH LED2
    else
    low LED2
    endif
    '***************** End Of Pushbutton Routine **********

    Goto mainloop ' Do it forever

  2. #2
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    YES! Its alive!

    It was a really simple problem, the R/W wire was not 100% connected LOL hehe, I feel quite silly :P

Similar Threads

  1. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 07:13
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 17:56
  3. cant get my Lcd to work using Pic18f452
    By civicgundam in forum General
    Replies: 13
    Last Post: - 7th October 2007, 01:13
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 27th June 2007, 00:07
  5. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 03:42

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