Go Down

### Topic: Stabilise potentiometer readings? (Read 2839 times)previous topic - next topic

#### amatic

##### Apr 24, 2012, 01:16 am
I'm using a 5k pot as an angle sensor for a robor arm joint, but I'm getting unstable readings (+- 2)
Software averaging is ok, but I would need to do it in hardware. Is this the best that can be done, or can I improve it somehow, by adding some capacitors (which ones) or perhaps using a lower resistance potentiometer?

#### Chagrin

#1
##### Apr 24, 2012, 03:46 am
The accuracy of the ADC of the ATMega chips is already +- 2. Also, the linearity of an inexpensive potentiometer is around 5%. I don't think you can improve what you have.

If you need more accurate values you would need to move to an optical encoder.

#2
##### Apr 24, 2012, 05:48 am

Analog read is 0 to 1023. You can use "map" and convert the reading to 0  to 360 degrees. You would get 3 times the less sensitivity or in a way it would seem like the potentiometer was 3 times more accurate because the noise would not show up as much.

If your scaling was 0 - 180 the effect would be even larger.

http://arduino.cc/en/Reference/Map
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

#### amatic

#3
##### Apr 24, 2012, 08:15 am

Thank you very much for your answers. I'll settle for this accuracy, and will use optical encoders for the next project.

Best
amatic

#### robtillaart

#4
##### Apr 24, 2012, 06:45 pm
Quote
I'm using a 5k pot as an angle sensor for a robor arm joint, but I'm getting unstable readings (+- 2)

you can use multiple readings and average them

value = 0;
for (int i=0; i< 16; i++) value += analogRead();
value /= 16;

or use a lowpass filter

value = value - 0.1 * (value-analogRead());  // same as  value = 0.9 * value + 0.1 * analogRead();  but optimized.

Difference the lowpass filter makes the system less responsive, and only needs one analogRead().

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Grumpy_Mike

#5
##### Apr 24, 2012, 06:50 pm
I think Chargin & cyclegadget are confusing accuracy and stability.

The normal stability for any A/D converter can only ever be +/- 1 so at a stability of +/- 2 there is room for improvement.
Yes a capacitor would help damp down any noise pickup. A 0.1uF across the wiper of the pot and ground will help. As will a software solution like that filter above.

#### amatic

#6
##### Apr 25, 2012, 10:25 pm
@Rob Tillaart
Yes, I am using the lowpass filter as a software stabiliser.

@GrumpyMike
Thank you, I will try the 0.1uF capacitor.

Go Up