Configuring Defines For 8-bit LCD


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well I do not want to start a new thread.
    Mainly,I thought that I needed 8 bit to LCD since I wanted 8 bit analog input, but that is not the case, SO I will stay at 4 bit to LCD. which works fine.
    Just my A/D conversion is not working. I have een playing around with ADCON0 AND ADCON1. I looked into PBP manual but no reference of ADCON0, AND THERE IS LITTLE on the spec sheet.

    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 0 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD

    ' 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 50 ' Set sampling time in uS


    adval var word
    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10000000
    ADCON0 = %00000101
    Low PORTB.2 ' LCD R/W line low (W)
    Pause 500 ' Wait .5 second

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

    Lcdout $fe, 1
    Lcdout "Value: ", DEC adval
    Pause 100
    Goto loop
    End

    end

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    as far as port I am using .
    RB4 to RB7 out to LCD
    RB0 RB1 as enable and register select bit

    RA analog input

    k

  3. #3
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Hi K,

    You can forget to set Register ADCON0, because it is complete done by PBP.

    The 16F876A has 5 analog inputs. If you want to use all of them, you should set the lower 4 bits of ADCON1 to "0000". Look at the datasheet !

    You WROTE, you want to use 8 bit ad-input.
    In your programm you USE 10-bit ad-input. Maybe you should define your parameters.
    Using 10-bit ad you have to choose right-justified results, because pbp doesn't convert it. So put a "1" it the MSB of ADCON1!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    hi

    I change these lines
    TRISA = %11111111
    ADCON1 = %10000010
    ADCON0 = %11000001

    and now it works, but it the output decimal value is never higher then 807, anyone know why

    k

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Post the schematic, so that we can see you ADC reading part.

    There should be a reference resistor for your ADC pin.

    That gives your reading a scale (mostly it is the way)


    -----------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Angry

    @sayzer
    You have to read the piclist-mailist too, because there is the same thread, but there he wrote, that his "sensor" only gives him 3,7-4 volts.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    It is working now, The reference voltage on the Pic chip had to be change to 4 volt from 5 v.


    thank you all

    ken

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 06:13
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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