You can filter/decouple in analog (as crossroads said) or in digital as well. Do averaging of the values (ie sum 32 pot measurements and divide by 32) or implement a low pass filter:
new_value=Aold_value+Bnew_value
where A+B=1, and the smaller the B (ie. B=0.2) the bigger the filtering effect.
P.
I've been struggling with this for a while. Perhaps a plain old 10k pot is too erratic for what I need, which is:
Dial in BPM (Beats per Minute) and convert to the microSeconds for the display.
I only want a range of 50-240 BPMs out of thing, but it has to sit there rock steady and musical.
I wanted to dial in the integer portion only with the pot, and have inc+/dec- buttons for the 1/10s of a BPM. A coarse/fine arrangement.
To eliminate a lot of things:
I grabbed a spare Arduino (Freeduino)
did the most basic analogRead() tut
tried the smoothing tut with numReadings up to 40!
tried the .1 uF cap over the middle and ground pins of the pot
tried different pots
did the software LPF with assorted values
various averaging algo's
I hear of people getting stable +/- 1, what am I doing wrong? Do I have to go discreet steppers like switches? Hope not, I don't need 6 switches for coarse, medium, fine +/- that would be unusable in low light conditions -or- by anyone that's ingested intoxicants.
Geez, I'd have this wrapped up in minutes if it were a software UI. I feel like such a stoopid boob.
I had a similar problem with an Arduino app that used an external 78l05 voltage regulator. The regulator had a low level oscillation at about 20 Mhz on the output. The problem went away when I added a 0.1 ufd cap across the regulator input.
While you might not think that word is offensive, remember this is a world forum and in the UK this is a very offensive word to use, and I don't mean potentiometer.
You will always get a reading +/- 1 out of any A/D converter, that is the nature of converters. You need to do one or more of the things you have been told about:-
Add some capacitors to smooth the output.
Add some software to take the average and thus smooth the output.
Implement a threshold so that you only consider a number to have changed when it is say 3 or 4 units away from the previous reading. When you detect this distance then increment (or decrement) the number and look again.
My regrets for using the "s" word. Here we use it to describe what someone being swarmed by mosquitoes looks like.
I've been doing more reading on the AREF as crossroads eluded to earlier, read your blog about decoupling, some forum archives here and on bildr.org, LPF on wiki. One thing I could improve upon is move the cap away from the pot and nearer the input pin on the Arduino.
I will hook the scope up and watch the changes I make to the circuit and see if I'm improving things. I was previoulsly trying to draw conclusions from the serial output.
From looking at the wave, it appears to be 1.75MHz Just wonder what else clocks at that frequency...
Hmm... ten cycles in 0.55 microseconds.. Looks more like 18 Mhz to me.
Take a 0.1 or 0.01 ufd capacitor, ground one end then poke around the circuit with the other end and see if you find a spot that removes the oscillation.
I am making some progress. Advice to put the coupling cap as close as possible to the Arduino pins is not to be ignored. I had the cap over the pins of the pot, moving it near the Arduino made a big difference. I will still need some additional smoothing from what I'm seeing so will try this averaging approach on the weekend. I can see light at the end of the tunnel.