Help with LCD


Closed Thread
Results 1 to 7 of 7

Thread: Help with LCD

  1. #1
    teknoman2420's Avatar
    teknoman2420 Guest

    Default Help with LCD

    the first code works with 4mhz but not 20mhz why
    and second code does not work with iether
    but is suposed to display ADC value on LCD
    from a thermister

    do the Defines for ADC need to be changed
    Thanks any help is great
    --------------
    ' PicBasic Pro program to display "Hello World" on LCD
    ' Auther mel
    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    DEFINE LOADER_USED 1
    DEFINE OSC 4
    ' Define LCD registers and bits
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 4000
    DEFINE LCD_DATAUS 50


    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10000010 ' Set PORTA analog and right justify result
    Low PORTE.2 ' LCD R/W line low (W)
    Pause 500 ' Wait for LCD to start up

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

    LCDOut "Hello" ' Display "Hello"
    Pause 500 ' Wait .5 second

    LCDOut "world" ' Display "Hello"
    Pause 500 ' Wait .5 second

    GoTo loop ' Do it forever
    End
    -----------------------------------
    ' PicBasic Pro program to display result of
    ' 10-bit A/D conversion on LCD
    '
    ' Connect analog input to channel-0 (RA0)

    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    DEFINE LOADER_USED 1
    DEFINE OSC 4
    ' Define LCD registers and bits

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 4000
    DEFINE LCD_DATAUS 50
    ' Define ADCIN parameters
    DEFINE ADC_BITS 10 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
    DEFINE ADC_SAMPLEUS 200 ' Set sampling time in uS

    adval VAR WORD ' Create adval to store result


    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10000010 ' Set PORTA analog and right justify result
    Low PORTE.2 ' LCD R/W line low (W)

    Pause 500 ' Wait .5 second

    loop: ADCIN 0, adval ' Read channel 0 to adval

    LCDOut $fe, 1 ' Clear LCD
    LCDOut "Value: ", DEC adval ' Display the decimal value

    Pause 100 ' Wait .1 second

    GoTo loop ' Do it forever
    End

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Are you using the Bootloader?
    Why you didn't change the DEFINE OSC to 20MHZ?
    Did you set the config fuses? i guess not.

    'It doesn't work' mean nothing. Wich part doesn't work? LCD or what?

    We don't have your PIC model
    We don't have your schematic

    We have nothing. How can we help you?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    teknoman2420, The second version of your code will not work @ 20 Mhz as you have not defined the oscillator frequency to be 20 Mhz. you need to change this line:
    DEFINE OSC 4 to DEFINE OSC 20 as well as change the actual crystal.

    Dave Purola,
    N8NTA

  4. #4
    teknoman2420's Avatar
    teknoman2420 Guest


    Did you find this post helpful? Yes | No

    Default more info

    sorry for not giving enough info
    i am working with a PIC16F877
    the config fuses are set to
    HS high speed enable
    code protect Disable
    WDT disable
    PWR enable
    WRT enable
    debug disable
    brown out enable
    LV programing disable

    now for LCD
    RS bit to PORTE.0
    E bit to PORTC.0
    RW to ground
    data bus to portB bits 4 to 7
    if i use Define osc 4 or Define osc 20
    makes no diference works the same
    but if i change the crystal to 4 mhz it works
    with the first code
    the bootloader will not load at 4 mhz
    i must swap it to 20mhz then back to 4mhz
    because my target file is for 20mhz and the pic is 20mhz
    i could change the target file to 4mhz but that dosn't solve the problem
    and i will learn nothing, i want to see why
    and it still dosn't work with second code for the thermister

    I programed my target file with the LAB-tool 48
    and although i am not working PIC16F876 28 pin
    i can't get any of my four 28 pin pics to work at all
    when programed with LAB-tool 48 even a simple blink test
    but the 877 will, i'm not sure if they got damaged
    from my other programer it was putting out 16V to pin 1
    when it was suposed to put out 13V to pin 1 for programming
    am i right about the voltage
    can this damage a pic
    but i'll find out someday when i order more pics
    this lab tool 48 is not the newer version or upgraded
    but supports the 40 pin 877 & 28 pin 876
    it also suports some of 18 series pics
    & 276 other pic micros
    and probly about 2000 other devices

    thanks i hope that helps
    Last edited by teknoman2420; - 20th August 2006 at 22:17.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK,
    Just to make sure everything is done properly, first you must load the 20MHZ bootloader file in your PIC, be sure the HS fuse is set before programming it, then, change DEFINE OSC 4 to DEFINE OSC 20 and last step, load your code in your PIC.

    Be sure you use the right capacitor values for the crystal, your PSU is properly filtered and it should work now.

    Good luck!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    teknoman2420's Avatar
    teknoman2420 Guest


    Did you find this post helpful? Yes | No

    Default ok it's working better but....

    it still jumps around a little,
    and not displaying correctly with 20mhz crystal
    and the value keeps changing too much
    why is that
    also when i put my fingers on the thermister
    it only changes from 686 to 750
    that's with 10K ohm resistor from portA.0 to ground
    that brings it down,
    and the thermister is connected at portA.0 to VDD 5V
    with thermister only it goes to highest value 1023 at 10 bit ADC
    and is at or close to 5 volts
    maybe i have wrong thermister
    or because i'm only changing the temp a few degrese
    am i doing it right
    i guess i'm learned a few thing anyway

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    teknoman2420, Have a look at app. note AN685 from Microchip which dives into attaching a thermistor to a microcontroller. A good reference.

    Dave Purola,
    N8NTA

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. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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