We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › averaging analog value
Page Index Toggle Pages: 1
averaging analog value (Read 596 times)
averaging analog value
Dec 29th, 2006, 4:05pm
 
Hi,
I started playing with my Arduino connected to an IR sensor.
The data received is a little erratic, I'd need to smooth it by averaging it, interpolating it.
I've found this:
http://www.tigoe.net/pcomp/code/archives/arduino/000710.shtml
but it s written in Wiring, should anyone have the similar lines written for Processing ?
Thanks, bonne annee.
eric.
Re: averaging analog value
Reply #1 - Feb 16th, 2009, 12:07am
 
Yes, I am also trying to do this using Processing software (+ Arduino board + Sharp IR Sensors) Did you or anyone figure this out using Processing Any code or hints would be helpful

some other posts of interest: http://www.arduino.cc/cgi-bin/yabb2/num_1213773881.html#2

some info on using capacitors: http://www.robotroom.com/DistanceSensor3.html
Re: averaging analog value
Reply #2 - Feb 16th, 2009, 10:22am
 
I never really did that, but I think a naive approach would be to use a sliding average: make a buffer of values (an array, or a Java queue); wait for the buffer to fill up, then compute the average of these values to output your first smoothed value. Then shift the values, dropping the oldest, entering the new one on the other end, compute the average again, etc.
Perhaps there are smart ways to update the average, if speed is critical. Like storing values divided by the buffer size, subtracting the outgoing value, adding the incoming one.
You can also compute the standard deviation, and eliminate values outside this range (spikes). It depends on the look of the input.
Page Index Toggle Pages: 1