ADC Channels


Closed Thread
Results 1 to 6 of 6

Thread: ADC Channels

  1. #1

    Post ADC Channels

    Hello. I have to read an analog signal and to convert it to a digital signal, but I just canīt get to do it. I know the adc has a 10-bit resolution right? Ok, so What bits are in adresh and wich ones are in adresl, and how cad a put that info in a port, say, portb. What is justified right and justified left? What does this mean? The analog signal goes from GND to Vdd (0V - 5V). So, in the Vref+ and Vref- should I have GND and Vdd?? I made a program but it does not work... hereīs the code. Please somebody help me yeah?

    osccon = $50

    ADCON1 = $0E
    ADCON0 = $02
    ADCON2 = $03
    high adcon0.0

    inicio:

    if (portc.1 = 1 and portc.2 = 0) then
    portb.0 = adresl.4 ; is this line right? I mean, is it valid to manage
    portb.1 = adresl.5 ; the data this way? If so, how can I know
    portb.2 = adresl.6 ; wich adres? to use?
    portb.3 = adresl.7
    else
    if (portc.1 = 0 and portc.2 = 1) then
    portb.0 = adresl.0
    portb.1 = adresl.1
    portb.2 = adresl.2
    portb.3 = adresl.3
    endif
    endif

    if adcon0.1 = 0 then
    high adcon0.1
    endif

    goto inicio

    uummm so... guess thatīs it. I will apreciate a lot any comment.

    Best Regards.

    Armando H.

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


    Did you find this post helpful? Yes | No

    Default

    That would help to know wich PIC you're using

    also
    Code:
    high adcon0.0
    you should write
    Code:
    adcon0.0=1
    AND
    Code:
    if (portc.1 = 1 and portc.2 = 0) then
    Should be
    Code:
    if (portc.1 = 1) and (portc.2 = 0) then
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    In addition to mister_e's post,

    If you are using 10bit resolution, "right justified" is needed.
    If you are using 8bit resolution, "left justified" is needed.

    Ex:
    ADCON0.7 = 1 'Right justified.
    ADCON0.7 = 0 'Left justified.


    Also, check this :
    http://www.picbasic.co.uk/forum/show...ight=justified
    Last edited by sayzer; - 13th September 2006 at 09:22.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4


    Did you find this post helpful? Yes | No

    Post ..

    Well thanks both of you. The pic I use is 18F4550. Iīm going to try out your advices, but there is still one thing Iīd like to know. If I need 8 bit resolution I have to use left justified, (thanks for that!) so, where will I find the data? Will it be stored in adresL or in adresH... and, if I decided to use 10 bit resolution, which bits would be sored is adresL and which bits in adresH? I think my questions are pretty clear but if I didnīt explain myself please let me know and thank you again.

    Regards.

    Oh, I forgot! I need to read a signal that goes 0-5 volts... how do you think I should use the Vref+ and the Vref-??? Thank you!!

    Armando H.
    Last edited by Armando Herjim; - 14th September 2006 at 07:12.

  5. #5
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    ADRESHI has the most signifigant bits, leaving ADRESLO with the least signifigant bits.

    The data from the A2D is 10 bits wide... so the question is where to put 10 bits into 2 seperate 8 bit result registers.

    If you left justify, you space everthing so the highest (most sig) data bit align with the highest (most sig) register bit.

    Right justify puts the lowest data bit in line with the register's lowest bit. That means the hi register only has the top 2 sig bits.

    When you left justify, as the hi register has the most sig 8 bits it also has the 8-bit (non rounded) result.

    Hope this is more helpful then confusing.

  6. #6
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi,
    you don't need to use 10 bit A/D. you can use 8 bit , that is easier than 10 bit.
    like this:

    define OSC 4
    TRISA = %11111111
    x var byte
    ADCON1 = %00000010
    adcin 0,x ' 0is the channel number and x is the variable
    end

    you don't need to connect the Vref+ and Vref- to somewher.

    if you want to use 10 bit ask me again yo tell you.

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  3. ADC - 2 channels but not same voltage reference - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th November 2007, 19:03
  4. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55
  5. Reading multiple ADC channels FAST
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st April 2004, 22:37

Members who have read this thread : 1

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