Potentiometer reading


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    I can never remember which one to use but I see you have the result, left-justified. Try right-justifying it instead and see if that helps (ADCON1.7=1).

    The resistance of your pot is 5 times the recommeded maximum impedance but I don't think it should make the readings unstable. Try increasing the sample time by changing the DEFINE ADC_SAMPLEUS 50 to something higher and see what happends.

    By the way, what do you mean by jumping from value to another? Is that a count or two or how much is it "jumping"? A little filtering might be all that is needed.

    And finally, since you have the ADC configured for external VRef, make sure you have proper decoupling on your VRef input.

    /Henrik.

  2. #2
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    Thanks Alain and thanks Henrik for the reply. I'm still new to ADC and so far I was able to make my LM35 work based on that code. As I understood in ADCON1 the four least significant bits controls the 8 A to D ports.
    ADCON1 = 000011 gives me
    PORTA.0,1,2,5 = A/D, PortA.3 = +Vref. Which now I think is not really what I need. I need only 3 ADC inputs and I don't have an external VRef for ADC..please correct me if I'm wrong, I should set it to either ADCON1 = 000010. But I still have the same results, please see the attached image to make it clear how the response look like and my pin connections.

    Henrik:
    Try right-justifying it instead and see if that helps (ADCON1.7=1).
    I tried that but as I slide to the fullest i have 3-4 reading only.


    Name:  Pot2.png
Views: 4920
Size:  20.0 KB

    Thanks and regards,
    tacbanon


  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    Hi,
    Ah, so you had it configured for external VRef but didn't use that - that would explain it. Strange it didn't help when you reconfigured...

    Have you verified the pot and connections, does the voltage at RA1 actually change when you sweep the wiper of the pot? Don't you have ANY other pot with lower resistance you can try with? If not just try with a simple resisotr divider.

    Since the forum messes up displaying binary numbers I'm going to write them in decimal instead.
    If you set the lower four bits to 0100 you'll get 3 analog inputs on AN0, AN1 & AN3 with Vdd/Vss as VRef.

  4. #4
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    Hi Henrik, I will try it to play it some more later tonight...and give feedback..
    If not just try with a simple resistor divider.
    Okay, I will try that later if nothing came up positive...

    Thanks and regards,
    tacbanon

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    Hi, tacbanon

    You should check that ...

    Define 20 OSC
    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    ... I just see 5 errors ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    what is your reference voltage?

    Ioannis

  7. #7
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Default Re: Potentiometer reading

    i use this and work
    DEFINE ADC_BITS 8
    DEFINE ADC_CLOCK 3 'Uses internal RC clock
    DEFINE ADC_SAMPLEUS 10 'Microsecond sample time
    My Hobbies is PicBasic PRO

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