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

    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

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Hi,

    i will continue here and not start a new thread.
    I am attempting to have two input values for an A/D conversion.
    I added these two lines and did some changes.
    How do I use the other input analog ports?

    ken


    ' PicBasic Pro program to display result of
    ' 10-bit A/D conversion on LCD
    '
    ' Connect analog input to channel-0 and channel1 (RA0, RA1)

    ' Define LCD registers and bits
    Define LOADER_USED 1

    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


    right var word 'Create right to store result
    left var word

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = 0
    ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %00000001 ' Configure and turn on A/D Module
    Pause 500 ' Wait .5 second


    loop: ADCON0.2 = 1 'Start Conversion

    notdone: pause 5
    if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished

    ADCIN 0, right 'Read channel 0
    ADCIN 1, left 'Read channel 1

    right.highbyte = ADRESH 'move HIGH byte of result to right
    right.lowbyte = ADRESL 'move LOW byte of result to right

    left.highbyte = ADRESH 'move HIGH byte of result to left
    left.lowbyte = ADRESL 'move LOW byte of result to left

    Lcdout $fe, 1 'Clear screen
    Lcdout "Value right: ", DEC right 'Display the decimal value
    Lcdout $C0, "Value left: ", DEC left 'Display the decimal value

    Pause 100 'Wait .1 second

    Goto loop 'Do it forever
    End

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the program still displays the first value at channel 0 , but not a the other channel 1.

    k

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


    Did you find this post helpful? Yes | No

    Default

    Remove these parts from your code


    ADCON0.2 = 1 'Start Conversion

    notdone: pause 5
    if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished



    and

    right.highbyte = ADRESH 'move HIGH byte of result to right
    right.lowbyte = ADRESL 'move LOW byte of result to right

    left.highbyte = ADRESH 'move HIGH byte of result to left
    left.lowbyte = ADRESL 'move LOW byte of result to left


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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    right var word 'Create right to store result
    left var word

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = 0
    ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %00000001 ' Configure and turn on A/D Module
    Pause 500 ' Wait .5 second


    loop: ADCON0.2 = 1 'Start Conversion

    notdone: pause 5
    if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished

    ADCIN 0, right 'Read channel 0
    ADCIN 1, left 'Read channel 1

    right.highbyte = ADRESH 'move HIGH byte of result to right
    right.lowbyte = ADRESL 'move LOW byte of result to right

    left.highbyte = ADRESH 'move HIGH byte of result to left
    left.lowbyte = ADRESL 'move LOW byte of result to left
    Here, inside a forum for PicBasic Pro-Compiler, it is allowed to use some of his commands.

    ADCIN 0,left
    ADCIN 1,right
    ...will do the job for you.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Lcdout $C0, "Value left: ", DEC left 'Display the decimal value

    use this for the second line:

    Lcdout $FE, $C0, "Value left: ", DEC left 'Display the decimal value

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    great its working
    thank you

    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, 20:54
  2. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 07:13
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  4. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 22:56
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02: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