Software > Software

Super Simple LPF DSPs.

<< < (2/2)


--- Quote ---takes the current reading from the sensor, averages with the last 5 sensor readings, and that becomes the "replacement" data value
--- End quote ---

I usually only use this method to get rid of noise . . . the problem with averaging this way is that your data is always outdated. Of course though, it also depends on things like robot speed, sensor rate, precision required, etc . . .

A modification to this is do a weighting, where older readings have a lower weighting than newer readings.

It was basically a simple way to get rid of noise. 5 readings happen in half a second, so the data isn't all that old...

- Jon

The weighting is the function of the coefficients that I mentioned.  In this example, I'm using all ones.  That's because I'm only looking to dampen down the signal.  It works well without the heavy math ops.

The delay for this FIR is two samples, if you take the delay to mean the center point of the phase shifts created by the four taps.

If you take the suggestion to eliminate the /4 and treat the data as if it gained two bits of resolution, then the whole filter is performed using only additions and subtractions, which makes it very fast.

The reason that I use the average of 4 values is because I find the use of 2^n and ((2^n)-1) a great way to stream line the code.  Notice the use of "AND 3" as the pointer MODULUS.

speaking of which I have some bouncy IR sensors... those pesky sharp kind...
should I use a capacitor? I'm trying to get readings every 50ms which is to fast to
do averaging because the sharps only update every 30ms....
any ideas?

Yeah, you definitely want a capacitor in there. Most people recommend putting a 0.01 uF ceramic cap very close to the sensor, between ground and power.

I typically put a big-ass electrolyte capacitor in my robots, on the 5 volt side of things. I usually use this one:

Coupled with a number of 0.01 uF ceramic caps in various places.

- Jon


[0] Message Index

[*] Previous page

Go to full version