Pages: [1]   Go Down
Author Topic: Noise reduction through deletion, not averaging.  (Read 2445 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to get a sound sensor to control a servo or motor they way a potentiometer would.  The problem is that the sound sensor hiccups a value to zero about every third millisecond or so, no matter the input.  This sends the servo wiggy.  I used a modified version of the smoothing example, but that cuts my highest results in half, and the thing is still kinda jittery.  All I want to do is to have the Arduino ignore a reading of 0.  I'm just not sure how to do that.  Please help.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8589
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well presumably at present you do something with the readings. So just don't do that something with a 0 reading.

if (getReading() != 0) {
   doSomething();
}

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perfect! Thanks for the help.
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 220
Posts: 13846
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


to generalize AWOL's solution :

#define MINIMUMSIGNAL 3

if (getReading() >= MINIMUMSIGNAL)
{
   doSomething();
}

furthermore instead of averaging you could use the median - http://arduino.cc/playground/Main/RunningMedian - to prevent spikes

Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: