Pages: [1]   Go Down
Author Topic: Is it the linearity of the Analog input affected by the potentiometer value?  (Read 1519 times)
0 Members and 1 Guest are viewing this topic.
Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 519
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

New England
Offline Offline
Sr. Member
****
Karma: 7
Posts: 295
Natural Semiinductor
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"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.
« Last Edit: August 21, 2013, 05:16:06 pm by AmbiLobe » Logged

I am going to get going.

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5972
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Windy City
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 21, 2013, 05:49:43 pm by DirtBiker » Logged

Dirt Biker

Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 519
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

... 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.
Logged

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.

Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 519
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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! 
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Lacey, Washington, USA
Offline Offline
Edison Member
*
Karma: 155
Posts: 2335
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with dc42. No noise issues with a rotary encoder as you'll have with potentiometers.
Logged

Steve Greenfield AE7HD
CET Consumer Electronics and Computer
Please don't read your attitudes into my messages

Pages: [1]   Go Up
Jump to: