• AVR Freaks

Potentiometer input

Page: 12 > Showing page 1 of 2
Author
PIC
Senior Member
  • Total Posts : 151
  • Reward points : 0
  • Joined: 2008/04/26 17:02:13
  • Location: 0
  • Status: offline
2008/07/11 20:15:23 (permalink)
0

Potentiometer input

Hello

I would like to provide an adjustable input to the input of an ADC pin. This will be in the form of a variable resistor arranged as a potentiometer.

When using a variable resistor in this way, does the resistance of the resistor (e.g. 1K or 10M) matter?
What is a better resistance?

Thank you

#1

25 Replies Related Threads

    Stefan Uhlemayr
    Super Member
    • Total Posts : 4292
    • Reward points : 0
    • Joined: 2005/05/12 12:25:46
    • Location: Germany
    • Status: offline
    RE: Potentiometer input 2008/07/12 00:11:40 (permalink)
    0
    ORIGINAL: PIC

    I would like to provide an adjustable input to the input of an ADC pin. This will be in the form of a variable resistor arranged as a potentiometer.

    When using a variable resistor in this way, does the resistance of the resistor (e.g. 1K or 10M) matter?
    What is a better resistance?

    Take a look into the datasheet for the max. recommend impedance of analog voltage source - you find this in the table "A/D converter characteristics" in the chapter "electrical characteristics". Usually this is 2.5k for a 10bit-a/d and 10k for a 8bit-a/d. So a 10M poti is much too high...

    Greetings,
    Stefan
    #2
    jpopelish
    Super Member
    • Total Posts : 314
    • Reward points : 0
    • Joined: 2003/11/07 12:39:20
    • Status: offline
    RE: Potentiometer input 2008/07/12 08:26:57 (permalink)
    +2 (1)
    It matters because it varies the amount of current from the supply that is consumed to produce voltage drop across the resistive element.  So, from that standpoint, higher resistance is better.

    But from the standpoint of ADC input time constant (the input is a sample and hold capacitor that has to charge up through the source resistance) and DC error (there is some finite leakage current from eother supply rail to that capacitor), lower source resistance is better.  For something as slowly changing as a pot position, the speed effect is a non issue, but the DC error problem remains, though pot settings often don't need the full precision from the ADC.  The worst case is also at high temperature, and that may or may not apply to your case.  The data sheet should quote a minimum source resistance to keep the DC errors insignificant over a specified temperature range.

    But keep in mind that the source resistance of a pot is highest at its midpoint setting, but even at that position it is only 1/4 of the pot resistance.  So a 100k pot has an effective spurce resistance at its mid position of only 25k ohms.  And since you don't need much speed capability (How fast can you turn a pot shaft to an intended position?), you can also lower the noise a bit by paralleling the ADC input with a capacitor that is much larger than the internal sample and hold capacitance.  This charges to the pot voltage continuously (and acts as an RC low pass filter), and then transfers charge to the internal cap very quickly when the ADC is switched to that signal, with little voltage change. 

    100nF is a common value for this effect. 

    John Popelish
    #3
    PIC
    Senior Member
    • Total Posts : 151
    • Reward points : 0
    • Joined: 2008/04/26 17:02:13
    • Location: 0
    • Status: offline
    RE: Potentiometer input 2008/07/12 08:56:49 (permalink)
    0
    Hello,
     
    Thank you for your replies and the explanation. I will go for the 1K.
     
     
     
     
     


     
     
     
    #4
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Potentiometer input 2008/07/12 12:14:44 (permalink)
    +1 (3)
    ORIGINAL: Stefan Uhlemayr

    ORIGINAL: PIC

    I would like to provide an adjustable input to the input of an ADC pin. This will be in the form of a variable resistor arranged as a potentiometer.

    When using a variable resistor in this way, does the resistance of the resistor (e.g. 1K or 10M) matter?
    What is a better resistance?


    Lets assume your PIC's data sheet says the PIC's maximum ADC input impedance is 10K.
    Using a 5 volt supply, you have one end of the POT connected to the positive supply.
    The other end of the POT is connected to ground.
    You are reading the voltage at the POT's wiper.
    Using a 20K linear POT, you are always 10K, or less, from a supply rail.
    So, a pot with a maximum of 20K ohms should do fine.
    post edited by paulbergsman - 2008/07/12 12:17:21

    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #5
    Stefan Uhlemayr
    Super Member
    • Total Posts : 4292
    • Reward points : 0
    • Joined: 2005/05/12 12:25:46
    • Location: Germany
    • Status: offline
    RE: Potentiometer input 2008/07/12 13:36:45 (permalink)
    0
    ORIGINAL: paulbergsman

    ORIGINAL: PIC

    I would like to provide an adjustable input to the input of an ADC pin. This will be in the form of a variable resistor arranged as a potentiometer.

    When using a variable resistor in this way, does the resistance of the resistor (e.g. 1K or 10M) matter?
    What is a better resistance?


    Lets assume your PIC's data sheet says the PIC's maximum ADC input impedance is 10K.
    Using a 5 volt supply, you have one end of the POT connected to the positive supply.
    The other end of the POT is connected to ground.
    You are reading the voltage at the POT's wiper.
    Using a 20K linear POT, you are always 10K, or less, from a supply rail.
    So, a pot with a maximum of 20K ohms should do fine.

    First: you shurely wanted to reply to John's post, or? In my post I was posting only the size of the max. allowed impedance of a voltage-source to the a/d-input, no calculation about the pot-size. So please take care to reply to the correct person next time.wink

    But John explained very well (and correctly!) how to calculate the source-impedance from a pot. Your explanation is not correct, a 20k lin pot has a source-impedance, which is always below 5k and not 10k, what you are assuming.

    Greetings,
    Stefan
    #6
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Potentiometer input 2008/07/12 18:30:13 (permalink)
    +2 (1)
    ORIGINAL: Stefan Uhlemayr


    But John explained very well (and correctly!) how to calculate the source-impedance from a pot. Your explanation is not correct, a 20k lin pot has a source-impedance, which is always below 5k and not 10k, what you are assuming.

    Greetings,
    Stefan


    I do not understand.  Why is the Pot's source-impedance  1/4 of it's resistance? Could you please explain?
    post edited by paulbergsman - 2008/07/12 18:32:44

    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #7
    jpopelish
    Super Member
    • Total Posts : 314
    • Reward points : 0
    • Joined: 2003/11/07 12:39:20
    • Status: offline
    RE: Potentiometer input 2008/07/12 18:48:41 (permalink)
    0
    ORIGINAL: paulbergsman
    I do not understand.  Why is the Pot's source-impedance  1/4 of it's resistance? Could you please explain?


    Look at it this way.  When the pot is set ot the mid resistance position, there is a resistor of half the total to one end of the pot to a fixed voltage and another resistance of half the total to the other end of the pot ot a fixed voltage.  So, as far as source impedance goes, the wiper is connected to two resistors in parallel, each half of the pot total resistance.  In  the case of a 10k pot, that is two 5k resistors in parallel, for an effective resistance of 2.5k.

    If you move the wiper, one resistance goes up and one goes down, but the parallel combination will be more affected by the lower than the higher, so all other positions must have a lower resistance (to some fixed voltage) than the mid position.

    John Popelish
    #8
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Potentiometer input 2008/07/12 19:07:26 (permalink)
    +2 (1)
    ORIGINAL: jpopelish
    Look at it this way.  When the pot is set ot the mid resistance position, there is a resistor of half the total to one end of the pot to a fixed voltage and another resistance of half the total to the other end of the pot ot a fixed voltage.  So, as far as source impedance goes, the wiper is connected to two resistors in parallel, each half of the pot total resistance.  In  the case of a 10k pot, that is two 5k resistors in parallel, for an effective resistance of 2.5k.


    I still don't understand. How are the two resistors in parallel?
    I would think the two resistors are in series, [forming a voltage divider], between the +supply and ground.
    post edited by paulbergsman - 2008/07/12 19:08:59

    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #9
    leon_heller
    Super Member
    • Total Posts : 6413
    • Reward points : 0
    • Joined: 2004/08/17 13:19:45
    • Location: St. Leonards-on-Sea, E. Sussex, UK.
    • Status: offline
    RE: Potentiometer input 2008/07/12 19:47:03 (permalink)
    0 (2)
    If you think in terms of AC impedance, the two ends of the track are effectively connected together.

    Leon


    Leon Heller
    G1HSM

    #10
    jpopelish
    Super Member
    • Total Posts : 314
    • Reward points : 0
    • Joined: 2003/11/07 12:39:20
    • Status: offline
    RE: Potentiometer input 2008/07/12 19:51:35 (permalink)
    +2 (1)
    ORIGINAL: paulbergsman
    I still don't understand. How are the two resistors in parallel?
    I would think the two resistors are in series, [forming a voltage divider], between the +supply and ground.


    From the power supply connections view point, yes, they are in series.  But if you were to inject current into the wiper, some would go through (or alter the current through) one half of the element ot its fixed DC voltage, and the other half of the current would go through (or alter the current through)  the other half of the element to its fixed voltage.  So, viewing the wiper as a source, it has both hlaves in parallel. 

    Have you ever heard of a Thevenin's equivalent for a circuit, where you convert an arbitrarily complex circuit into a voltage source and a series resistance that performs the same as the circuit at one node?  

    In this case, the equivalent voltage source would be whatever voltage you would have on the wiper if it is connected to no load.  In this example, of a 10k pot at mid position, with the element connected from +5V to ground that would be 2.5 volts. 

    The effective series resistance would be that voltage divided by the current you would see from that node if you shorted it to ground.  In this case that current would be what the 5 volt supply would push through the 5k half resistance or 1mA.  So the Thevenin's equivalent resistance is 2.5V/1mA=2.5k ohms.



    John Popelish
    #11
    MrCal
    Super Member
    • Total Posts : 266
    • Reward points : 0
    • Joined: 2006/11/12 12:27:18
    • Location: 0
    • Status: offline
    RE: Potentiometer input 2008/07/12 19:56:25 (permalink)
    +4 (2)
    Hi there Paul,

    Very sorry to have to disagree, but yes the two parts of the pot are in parallel.
    Believe it or not this comes from basic engineering circuit analysis which can
    be obtained by examining the current and voltage from the pot arm, but i can
    offer a more intuitive explanation...

    Consider a 40k pot from +5v to ground with the arm connected to the AD input
    of the PIC.  It 'seems' like the max impedance might be 20k because the arm
    is never more than 20k away from any supply line.
    Ok, so now lets reduce the +5v to +2.5v.  Now the pot is connected between
    +2.5v and ground.  What is the max impedance presented to the AD port now?
    Ok, now lets reduce that +2.5v even further...to +1.00v...now what is the
    max impedance?
    Now again, reduce that +1.00v to +0.100v (one tenth of one volt)...now
    what is the max impedance?
    Now finally, lets reduce that +0.100v to 0.000v (zero), what is the impedance
    presented to the AD port now?  Since 20k in parallel with 20k is 10k, it's
    got to be 10k (max).

    The real key here is that any true voltage source has an impedance of Zero,
    so that means the impedance from +5v to ground is zero and of course
    so is ground itself, so we can calculate the total impedance by shorting the
    top of the pot to the bottom of the pot (ground) and looking for the max
    setting by adjusting the pot.  It happens to be midway, so that's 20k in
    parallel with 20k.

    If you need further proof, i'll present the math for a complete dc analysis.
    This would show that the current flowing into the AD port is the same as that
    of the voltage divider effect as a voltage source in series with a 10k ohm
    resistor.  For a 40k pot and a +5v supply, the equivalent would be a 2.5v
    voltage source in series with a 10k ohm resistor in connected to the AD port.

    Just as a side note, a 50k pot would not be too far off although not ideal.
    A 1M pot on the other hand would be way too big.

    Just as another side note, at 25 degrees C 100k works too.  It's mainly
    a problem when the temperature changes, which usually has to be taken
    into account.

    #12
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Potentiometer input 2008/07/12 20:06:55 (permalink)
    +2 (1)
    To both JPopelish, and MrCal,

    Thank you both. I was treating impedance as resistance.
    You have put me on the right track to doing some refresher investagation of impedance.

    thanks again


    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #13
    MrCal
    Super Member
    • Total Posts : 266
    • Reward points : 0
    • Joined: 2006/11/12 12:27:18
    • Location: 0
    • Status: offline
    RE: Potentiometer input 2008/07/13 07:21:16 (permalink)
    +6 (3)
    Hi again Paul,


    It's the ol' intuition kicking us in the back end again...
    I cant count the number of times my intuition failed me on twenty feet and twenty hands :-)

    The next intuitive thing that pops up is that since the 40k pot has a 20k to
    +5 and 20k to ground perhaps a 1ua current source (the internal AD of the PIC for
    full temp range approximately) causes a 0.02v change at the arm of the pot.
    Doing a quick analysis, actually a 1ua current source changes the arm of the pot
    by only 0.01v, which is again what would happen with a 10k impedance.

    The next intuitive thing that usually pops up is that maybe since the 40k pot has 20k
    to +5v (typical hookup) that a cap being charged from the arm of the pot charges slower.
    As the waveforms below show, the 40k pot to +5v and the 10k resistor to +2.5v really
    are true equivalents, even with more dynamic circuits like that of the input of the PIC's
    AD converter (the small cap charges from the external impedance).
    Note that the two waveforms are identical.



    Attached Image(s)

    #14
    Neiwiertz
    Super Member
    • Total Posts : 2131
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: Potentiometer input 2008/07/13 14:47:09 (permalink)
    0
    Hi MrCal

    I found the picture shown interesting, may i know which sw you have used to produce that waveform. (Proteus can draw that kind of graphs if i do remember correctly,  i am just curious how you made that graph)

    Cheers

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #15
    bobtron
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2008/04/04 21:15:09
    • Location: 0
    • Status: offline
    RE: Potentiometer input 2008/07/13 17:11:31 (permalink)
    0
    ORIGINAL: Neiwiertz

    Hi MrCal

    I found the picture shown interesting, may i know which sw you have used to produce that waveform. (Proteus can draw that kind of graphs if i do remember correctly,  i am just curious how you made that graph)

    Cheers


    So can OrCad's PSpice
    post edited by bobtron - 2008/07/13 17:18:09
    #16
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Potentiometer input 2008/07/14 02:27:14 (permalink)
    +2 (1)
    ORIGINAL: MrCal
    [image]local://39878/0D4D5F625BAE4BB5A88AD942C51C19A4.gif[/image]


    They say a picture is worth a thousand words.

    NOW I understand the error in my thinking.

    I woke up brain dead last week.  I was looking at the ADC input as DC. Impedance is an AC characteristic.
    Many posts could have been avoided, if I had more carefully read ipopelish's orginal responce, [in post 3]:

     
    "....(the input is a sample and hold capacitor that has to charge up through the source resistance)"....
    post edited by paulbergsman - 2008/07/14 03:12:00

    Paul Bergsman, N3PSO


    For the most cost effective PIC prototyping board around:
    http://mysite.verizon.net/vzes94mj/picprototypingboard
    #17
    assaad
    Super Member
    • Total Posts : 2504
    • Reward points : 0
    • Joined: 2006/03/27 22:51:42
    • Location: Turkey
    • Status: offline
    RE: Potentiometer input 2008/07/14 03:18:14 (permalink)
    0
         I did not read the thread from begining , but usually we put a resistor and cap before the input of the A/D , the purpose is to construct a simple LP filter , if the pot is going to be changed by a  human being , so 100 Hz  filter would be enough . You might need clamping fast diods to limit the voltage , that only incase your POT supply is greater than 5V.
     
          If the thevenin imepedance seen by the POT is greater than 2K5 , you should use opamp to match the impedances , otherwise you might get wrong readings or less resolution .
     
     
    ..V1(from POT)>>>>>>>>RESISTOR>>>>>>>>>>A/D PIC
                                                     V
                                                     V
                                                     V
                                                   -------     CAPACITOR
                                                   -------
                                                     V
                                                     V
                                                      GND 

    S. ASSAAD
    #18
    MrCal
    Super Member
    • Total Posts : 266
    • Reward points : 0
    • Joined: 2006/11/12 12:27:18
    • Location: 0
    • Status: offline
    RE: Potentiometer input 2008/07/14 08:30:06 (permalink)
    0
    Hello again,


    Neiwiertz:
    Any circuit analysis program should be able to do this, if not directly
    then you can use the "Print Screen" button on your keyboard and then
    paste it into your favorite drawing program and go from there.
    I do this actually, and then convert the drawing to .gif format
    because that takes the least amount of bytes for most schematics
    (better than jpg or bmp for schematics).
    BTW, those waveforms were made using a circuit analysis program
    on the two circuits on the left.  If you dont have one, check out
    LT's SwitcherCad software, which is free to download and use.

    Paul:
    "They say a picture is worth a thousand words."
    Yes i agree, and i like to draw schematics and waveforms whenever
    possible, but obviously this takes a lot of time so i cant always
    do this.

    assaad:
    Yes, some PIC require a max of 2.5k impedance, not 10k.  The
    user would have to check their data sheet carefully to determine
    which applies to their PIC chip.

    #19
    CraigHB
    Super Member
    • Total Posts : 244
    • Reward points : 0
    • Joined: 2007/04/18 22:01:21
    • Location: Reno, Nevada
    • Status: offline
    RE: Potentiometer input 2008/07/14 14:55:37 (permalink)
    0
    All the PIC's I've worked with have a 2.5K impedance specification for the ADC, but I don't believe it's a hard and fast rule.  I've been able to get the ADC working reliably with a 10K impedance by ensuring there's enough charge time for the ADC's sampling capacitor. 
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2021 APG vNext Commercial Version 4.5