Software > Software

Super Simple LPF DSPs.

(1/2) > >>

Let's say that you have some real time signal data streaming in and you want to make it less "bright."

There are two common methods that are used.  One is the decimation and interpolation method.
To decimate and interpolate by two, simply throw out every other sample, effectively reducing your sample rate by half.  Then average the two samples on either side of each new vacancy and use the result as the replacement value for that missing sample.

The other way to dim down your data stream is to use an optimized Finite Impulse Response (FIR) filter.

Private LPF(3) As Long   //  Use a tiny array to hold your data history.  Normally, with an FIR, you   
Private x As Long           //  would also have a coefficient table.  This FIR will assume that all
Private y As Long           //  coefficients are 1, allowing us to omit those multipication operations.
Private i As Long

y = input

Private Sub LPF_DSP()
  LPF(i) = y
  For x = 1 To 3
    y = y + LPF((i + 4 - x) AND 3)
  Next x
  y = y / 4                     // Replacing this division by 4 with two arithmatic shifts
  i = (i + 1) AND 3          // will speed up the execution of your code considerably.
End Sub                        // You can also skip this "normalization" step and treat
                                    // the data as if it had gained two bits of resolution.

The output is contained in the variable y, just as the input was.  You'll need to call this routine once for every new sample taken.

Let me know if you find this kind of post helpful.   

maybe a definition of lpf and dsp and what they are used for in the real world...
are they used for audio sampling, rf sampling.... ???

Good point.

An LPF is a Low Pass Filter.  It is used to dampen down a digital signal, removing some or all of it's high frequency content.

A DSP is a Digital Signal Process.  It describes a wide variety of algorhythms used to process digital signals.

In the real world, analog signals are converted to digital signals before they can be stored and analyzed by a computer.  You can find LPFs and other DSPs in everything from car stereos to SONAR.  Any signal, be it a recorded sound, radio telescope data or a RADAR image can be processed by a DSP.

An example of a robot oriented LPF application is sensor data stabilization.  It smooths out the sharp bumps.

I have done something similar with my depth sounder sensor readings from my AUV MicroSeeker. The algorithm is a lot simpler - it just takes the current reading from the sensor, averages with the last 5 sensor readings, and that becomes the "replacement" data value. Note that the averaging is always done with the actual history, not the averaged data.

You can see the result of this fairly clearly here:

This first graph is the actual depth sensor readings - it has 4" of resolution with a 10 bit A/D converter.

This is the smoothed data:

It makes quite a difference...

- Jon

I liked your idea of including a picture - so I copied.   ;D


[0] Message Index

[#] Next page

Go to full version