Go Down

Topic: Is it the linearity of the Analog input affected by the potentiometer value? (Read 3511 times)previous topic - next topic

Palliser

I do not know exactly whether this topic has been discussed here before, but given that neither the  'Reading a Potentiometer' Arduino tutorial not the Analog Input example sketch specifies a resistance value or range for the potentiometer to be used, and knowing that the Analog input of the Arduino board (UNO, DUE, Leo, etc.) has a non infinite internal resistance (I have measured values between 300K to 1M), I wonder if someone here has spent time verifying if the value of the potentiometer affects significantly or not the linearity (voltage vs. the bit resolution (values)) of the Analog input. I mean, is it relevant the value of potentiometer if we need linearity (i.e linear pot dialed 50% should gives Vref/2 and (max. bit-resolution)/2 no matter its resistance)? Regards!

AmbiLobe

#1
Aug 22, 2013, 12:14 amLast Edit: Aug 22, 2013, 12:16 am by AmbiLobe Reason: 1
"I wonder if someone here has spent time verifying if the value of the potentiometer affects significantly or not the linearity (voltage vs. the bit resolution (values)) of the Analog input."

No.

"I mean, is it relevant the value of potentiometer if we need linearity (i.e linear pot dialed 50% should gives Vref/2 and (max. bit-resolution)/2 no matter its resistance)? "

Yes, but have some tolerance for imprecision. A 1% tolerance on your part will be more satisfying than a 2% tolerance for the granularity and quantization of discrete windings on a mechanical sweeper. You already measured 300k ohms for the Arduino input. So you can use the voltage divider equation to select a pot within your tolerance in a precision goal.

SurferTim

Be aware there are two common types of potentiometer tapers. Linear and log (audio). The linear taper is linear, The log taper is not.

DirtBiker

#3
Aug 22, 2013, 12:36 amLast Edit: Aug 22, 2013, 12:49 am by DirtBiker Reason: 1
Let's take a quick look.  Assume a 100K pot. Assume the leakage current on an analog I/O pin could be as much as 1.5uA.  Across a 100K resistor that would amount to about .15V or about 3%, which for 10bit ADC is quite high.  I'd say you'd need to be more in the 10K Ohm range and use a cermet pot if linearity is truly important to you.

Edit:  BTW, this is what is referred to as a 'back of the envelope' calculation.  The idea was to get in ballpark, not work it out ot 10-24 precision.  So, all the AR types, relax.

Palliser

According to Atmel's ATmega328p doc8161, p.257 (Arduino UNO case, my case):
http://www.atmel.com/Images/doc8161.pdf

Quote
"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."

Thus, for the case of a potentiometer (not varying signal, also my case) appears to be the linearity will be the same, regardless of the impedance (pure resistive, Zc = 0, Zl = 0). Thank you AmbiLobe, SurferTim and DirtBiker for you comments.

dc42

... knowing that the Analog input of the Arduino board (UNO, DUE, Leo, etc.) has a non infinite internal resistance (I have measured values between 300K to 1M) ...

Looks like you have measured incorrectly. From the datasheet, the ADC has a typical input resistance of 100M. However, if you read from more than one analog pin, then with source resistances greater than about 10K, you will get crosstalk between the readings, due to insufficient sample-and-hold time. Unfortunately, the analogRead code in the Arduino core switches the ADC multiplexer to the desired pin and then starts the conversion in the very next instruction, which provided the very minimum sample-and hold time. Patching the source (wiring_analog.c) to include a delayMicroseconds call (right at the place where there is a commented-out delay(1) call) allows the use of higher input resistances without crosstalk. 1us of delay per additional 10K source resistance is usually sufficient. Alternatively, if the voltage you are measuring changes only slowly (e.g. because the pin is connected to a pot), just connect a 0.01uF or greater capacitor between the pin and ground.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Palliser

Hello dc42,
Thank you for your note regarding the use of a source resistance greater than 10K. I am planning to build a sine-wave generator using UNO (10-bit res.) and then DUE (12-bit res.) with a couple of pots to adjust the amplitude and frequency. That's why I started considering linearity. I will certainly reread your notes during my design. Thank you very much.

By the way, I have decided to keep this post open in the event that issues arise during my design. Regards!

dc42

Why not use a rotary encoder to select the frequency and amplitude, and an LCD display to show them? That way, you can set them accurately. You can use a single encoder with a built-in push button, by using the push button to select between frequency and amplitude adjustment. Or use 2 separate encoders if you prefer.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

polymorph

I agree with dc42. No noise issues with a rotary encoder as you'll have with potentiometers.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8