how to get an analog potentiometer to settle down?


Closed Thread
Results 1 to 12 of 12
  1. #1

    Default how to get an analog potentiometer to settle down?

    I'm working on a project that uses the ADC to read an analog potentiometer. It's causing problems for me when the voltage on the ADC fluctuates slightly. Like when the voltage it's reading is 2.4955V and the ADC can't make up its mind whether it's 2.49V or 2.5V. Is there a way to make the voltage settle down?

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    Can I decrease the resolution of the ADC?

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    or just round the output .
    George

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    Quote Originally Posted by towlerg View Post
    or just round the output .
    How do I do that? Is there a command line that will round up or down?

  5. #5
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    Yes, there is such command, but I don't remember it's name, check the manual, it was something like I=I<<I or whatever.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    If you DEFINE ADC_BITS 8 it will grab the 8 high bits of the 10bit result from the ADC, you'll leave the noise in the lower two bits but at one point or another you're still going to be on the edge where the 3rd bit is flipping back and forth and you're back at square one.

    You can always take multiple samples and average them to smooth things out a bit.

    /Henrik.

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    Try adding a bit of capacitance from the wiper of the pot to ground - say 100nF.
    This should minimise some of the variations you are experiencing.

    Cheers
    Barry
    VK2XBP

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


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    KeithV, You could always low pass filter the A/D reading if you are not requiring the responce speed. If you require the speed then just read the A/D faster. Something like this:

    FILTG CON 32 'FILTER CONSTANT (255 = NO FILTER, 1 = MAXIMUM FILTER)

    VOUT VAR WORD 'FILTER HISTORY

    LOWPASS: '------------------- LOW PASS FILTER --------------------------
    VOUT = VOUT - (VOUT */ FILTG) + A_D_READING
    FILTERED_VOLTAGE = VOUT */ FILTG 'FINAL FILTERED OUTPUT COMPUTED
    RETURN

    I use something similar to it all the time....
    Dave Purola,
    N8NTA
    EN82fn

  9. #9
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    How do you have the 2.4955V in memory? Is that a word? Because that wouldn’t give you much range past 6 Volts.

    You can keep the resolution and take the mean of the last n readings if you can calculate it, which you probably can.
    The larger n is, the less responsive your potentiometer is, at least “apparently”,
    but the smaller the fluctuation you see, the easier it is to pad out.

    If you’re going to blow out a variable used to calculate the mean, you can add and divide small groups of variables
    to arrive at a new smaller group of variables, and work down to one number that way.

    Heart rate monitors at least used to do this because the interface to the body, and radio between the chest sensor and device was so clumsy.

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    I tried adding a cap to ground off the wiper. That seemed to help a tiny bit, but not much.

    I had the same idea about sampling and averaging in the shower this morning. Unfortunately, I haven't had a chance to try it yet. I'm using a 16F676 which only has 1023 words of program memory, and I've already been "trimming the fat" to get what I've already got working on there. I need to use a PDIP14, so my options are limited. I just ordered some 16F616, so that should give me twice the memory.

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    There's plenty of modern options in 14 pin packages.
    16F1503 is pin compatible, has twice the amount of flash and twice the amount of RAM and costs less than 16F630.
    If you need even more then 16F1507/8/9 are all "the same", just more flash and RAM.

    Plenty of other to choose from as well.

    /Henrik.

  12. #12


    Did you find this post helpful? Yes | No

    Default Re: how to get an analog potentiometer to settle down?

    I haven't tried the sampling/averaging fix yet. I'm having some trouble with the new 16F616. With the 16F676, the only problem I had was with the pot not wanting to settle. Now, there's all kinds of problems with the 16F616. It seems like the primary difference between the two chips are the comparators. I'm a little confused by the differences between the 16F676's CMCON register and the 16F616's CM1CON0 and CM2CON0 registers. Seems like if I want CM1CON0 to be configured the same as CMCON = %00000111, I would write it as CM1CON0 = %00000000, but the last 2 bits are a little confusing to me. Do I need to configure both the CM1CON0 and CM2CON0 registers?

    Also, could the way I have ADCON1 configured be causing trouble? Seems like FOSC2 is what I want. Faster is better, right?

    Below is the configuration section of my code for the 16F616. Sorry for so many questions. I'm still pretty new to this.

    Code:
    #config 
        __CONFIG _CP_OFF & _WDTE_OFF & _BOREN_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF
    #endconfig
    
    
    ADCON1 = %00000000
    ANSEL = %00000110
    CM1CON0 = %00000000               'program worked previously with 16F676 CMCON = %00000111   
    
    TRISA = %00001111
    TRISC = %00000000
    
    ' Set TMR0 to interrupt every 16.384 milliseconds
       OPTION_REG = %10000101        ' Set TMR0 configuration and enable PORTB pullups
       INTCON = %10100000           ' Enable TMR0 interrupts
       On Interrupt Goto tickint

Similar Threads

  1. Potentiometer reading
    By tacbanon in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 9th January 2012, 02:19
  2. Servo speed, from potentiometer
    By CipiCips in forum mel PIC BASIC
    Replies: 2
    Last Post: - 20th May 2011, 09:26
  3. Using sound/audio as a potentiometer?
    By mekohler in forum Schematics
    Replies: 5
    Last Post: - 24th October 2007, 21:53
  4. Switch / Potentiometer
    By bearpawz in forum Off Topic
    Replies: 12
    Last Post: - 19th January 2007, 22:45
  5. Potentiometer with indexing.
    By muddy0409 in forum General
    Replies: 2
    Last Post: - 1st January 2006, 20:41

Members who have read this thread : 2

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