best practices for interfacing with pots?

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need to hook up a couple of pots to the ADC inputs of an AVR. Is there anything "wrong" with this design:

1. AREF = Vcc = +5V
2. pot ends are connected to Vcc and GND with wiper connected to an ADC input pin

The pots would be the normal kind like what is typically used in joysticks.

I'm interested in unexpected failure modes of the pot which could cause problems. Can pots short? Is there a problem if the wiper loses contact with the resistive material in the pot? Are there any problems with trying to use an AREF which is close to Vcc?

Also, I want to have a resolution of 256 steps when reading the pot. To compensate for the particular dynamic range of a pot, what about using the following calibration procedure:

When a certain button is pressed, the uC goes into calibration mode. In this mode the user moves the pot to its extremes. The uC will reads the pot using 10-bit ADC and record the extreme values in its EEPROM. In normal operation the uC reads the pot value using 10-bit ADC and determines an 8-bit value by interpolating the value read between the two extremes stored in the EEPROM.

I just want to make sure this is reliable in practice. Any comments?

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is there anything "wrong" with this design

No. This is how it is normally done.

Quote:

To compensate for the particular dynamic range of a pot

Could you elaborate? When the wiper is swung all the way in one direction it should be at VCC (more or less), and in the other direction at GND.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A joystick that travels +-45 deg might have a 90 deg pot in it. I've seen regular pots driven by a sector gear on the joystick... obviously more expensive, but uses the fiull throw of the pot.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You never gave the value for your pots. Did you read this part of your data sheet?

Typical Data Sheet wrote:
The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Uh! Missed the joy-stick part. Gotta go check on mine...

Bourns joystick with 10K pots (http://www.mouser.com/search/ref...)

It actually looks like the pots have resistive tape just over the 60 degree operating angle, but at one endpoint I read 1.5 KOhm other endpoint 1.9 KOhm. Endpoint to endpoint I read 9.1 KOhm. An error of 10%. Either that or my DMM is bad.

circuitmangler: Your calibration scheme should work.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would also suggest putting a small cap between the wiper of the pot and ground. This helps to reduce any transients on Vdd since the AVR and other high speed logic is running on Vdd.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may put resistor (eq 10k) beetwwen the wiper of the pot and ADC input. This prevent from direct connection of ADC input to Vcc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If needed I would suggest a resistor between the fixed top terminal of the pot and Vcc. The resistor value would be selected such that the pot wiper never has a higher voltage than AREF. However, since the OP already said AREF is the 5 volt Vcc, there is no need for a voltage divider resistor.

If a 10 k resistor is placed at the ADC input, then the impedance for the sample and hold capacitor would already be maxed out with the pot wiper at ground. As the pot setting is increased the impedance will get too high and the ADC might not work so well. The worst case position would be approximately midway for a linear taper pot. Assuming Vcc has a low impedance and ground is the lowest possible impedance, about the halfway position would have the highest total impedance for the ADC input.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks everyone, this really helps. I don't know what my pot values are right now, but if they are too big (like 50K ohms or greater), what would you do then? My first approach would be an op-amp voltage follower buffer. This would necessitate a rail-rail op-amp, right? Does anyone have any favorites to recommend?

Thanks again!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Instead of worrying about input impedance and all that fun stuff - why not just buffer it? Put a 5V rail to rail op-amp on it and forget about it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For what you are proposing you can probably skip the EEPROM & linear interpolation business. You can set the a/d config reg to provide an 8 bit result.

Or better yet, take a few (say 4) 10 bit readings, add them up and divide by 16 (by shifting right 4 places)to get a nice averaged 8 bit result (0 to 255).

Start simple & see if this gives you what you need.

A plastic condutive pot has better resolution than most other types. You should check the linearity specs. That might be cause for a multisegement linear interpolation.

If the pot is mounted far away (cable) you might use twisted pair or shielded cable.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Assuming Vcc has a low impedance and ground is the lowest possible impedance, about the halfway position would have the highest total impedance for the ADC input.

This impedance will be 1/2 of your pot's total ohms(eg:a 10k pot will give 5K)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After seeing this design for a AVR joystick:

http://www.arduino.cc/en/Tutoria...

I guess I'd like to know exactly what the consequences are if you read a high impedance signal with the ADC. Is it:

A) the reading takes longer so your sample rate is decreased
B) the reading loses accuracy
C) both or something else?

For a sample rate of ~ 100/sec, and an input impedance of 100K ohms, will the AVR's ADC work "well enough"? (7 bits of precision would be fine although more would be better)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The sample cap charges from the source impedance. If the cap doesnt get charged in the 1.5 cycles avail, the reading is too low. Fix is have a cap from the pot wiper to ground. Now the source impedance is low. Problem solved.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I guess I'd like to know exactly what the consequences are if you read a high impedance signal with the ADC. Is it:

A) the reading takes longer so your sample rate is decreased
B) the reading loses accuracy
C) both or something else?

For a sample rate of ~ 100/sec, and an input impedance of 100K ohms, will the AVR's ADC work "well enough"? (7 bits of precision would be fine although more would be better)


All of the above, somewhat. The adc can be thought of as a small capacitor, which at the time of conversion must be charged/changed to the voltage on the input selected by the adc input multiplexer. If the resistance at a particular input is high, the capacitor won't reach the desired voltage quick enough and an error in the reading can result. If you are reading multiple analog inputs, the charge on the capacitor from one input will be carried over to the next input being read, and can affect the new channel's reading if it's resistance isn't low enough to promptly "reset" the capacitor voltage to the new signal's level. The cure for this is very simple. Simply provide a small capacitor from each analog input pin to ground that is being fed from a high resistance source. This provides a low resistance "reservoir" that will instantly bring the adc's capacitor to the proper voltage when the input is selected for conversion. Now you can use high value pots with no problems other than the small time constant you now have because of the cap from the pot's wiper to ground. This should be insignificant in your application. One thing to remember, too, is that there is always a tiny amount of "leakage" current that will flow out of or into the adc input that can introduce an error on an input driven with a high resistance. This leakage current is spec'd in the data sheet.

Tom Pappano
Tulsa, Oklahoma

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bob and tom - thanks for the help!