Arduino Forum

Topics => Robotics => Topic started by: amatic on Apr 24, 2012, 01:16 am

Title: Stabilise potentiometer readings?
Post by: amatic on 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?

Title: Re: Stabilise potentiometer readings?
Post by: Chagrin on 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.
Title: Re: Stabilise potentiometer readings?
Post by: cyclegadget on 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
Title: Re: Stabilise potentiometer readings?
Post by: amatic on Apr 24, 2012, 08:15 am
Chargin & cyclegadget

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

Best
amatic
Title: Re: Stabilise potentiometer readings?
Post by: robtillaart on 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().




Title: Re: Stabilise potentiometer readings?
Post by: Grumpy_Mike on 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.
Title: Re: Stabilise potentiometer readings?
Post by: amatic on 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.