top of page
Wind Turbines on Water

FILTERING

Reducing Noise Real time

Coming into this project, our initial plan was to use a moving average function to smooth out the sensor output data. Through trial and error, we eventually found that the desired results were most closely achieved using an exponential moving average filter for the IR sensor data and a leaky integrator for the EMG sensor data.

IR SENSOR

RAW SIGNAL

An unfiltered input of the IR sensor is given below. A button was pressed when the user intended to flex.

Screen Shot 2020-12-09 at 7.29.40 PM.png

MOVING AVERAGE

Initially, we used a moving average filter - a DSP tool given to us in class. The intended purpose was to keep the flexing inputs while smoothing out the noise. Since we want to detect flexing ‘online’ or real time, the moving average filter also had to be a causal system. Therefore, the average only took values at or before index n.

​

The moving average equation was of the following form:

Screen Shot 2020-12-09 at 7.27.24 PM.png

MOVING AVERAGE EFFECTS

Below shows the original signal filtered by different moving averages, which vary in their span - how many data points they average together.
It interested us to to find that the moving average acts very similarly to a low pass filter.

Screen Shot 2020-12-09 at 7.31.37 PM.png

DISADVANTAGES OF MOVING AVERAGE

Some disadvantages with this type of moving avg filter is as follows: The more indices you use for the average filter the smoother the signal, but also the more attenuated the flexing signal is. Since we don’t want to reduce the desired signal, this is not ideal, because it reduces the signal when we are trying to reduce the noise.

 

Also, a negative effect as you can see is that the filtered signal is delayed from the original signal. Including more past indices makes the filtered output more delayed. This is an effect of using a causal system.

EXPONENTIAL MOVING AVERAGE

Screen Shot 2020-12-09 at 7.39.41 PM.png

The next method we tested for filtering was the Exponential moving average. One benefit of using this type of filtering is it uses a recursive formula, which is faster computation wise on the microcontroller. As you can see in the formula below, the filtered output (denoted by x bar) only depends on the previous filtered output and the current input. The weights associated with each can be adjusted with the forgetting factor - or lambda - to fine tune the effect of the filter. Another benefit of this filter is it can better preserve the features we want to keep in the signal. In our case, we used a lambda of .5 - which corresponds to the graph in the middle. We found it gets rid of some of the low level noise without affecting the main dips too much.

Screen Shot 2020-12-09 at 8.10.58 PM.png

With the first Weight W = 1;

​

In Matlab we can use the function:   dsp.MovingAverage('Method','Exponential weighting','ForgettingFactor',value); to create an Exponentially weighted moving average.

 

The Exponential Weighting filter has many benefits: Since it is a recursive definition and only depends on the current input and last weighted input, there is less processing that needs to take place within the controller. Along with that, the weighted nature of the algorithm will allow us to adjust the impact of the old data vs new incoming data and therefore try to not attenuate the signal we desire to keep.

​

Below, we have filtered outputs with two different forgetting factors of .5 and .85 respectively, along with the original signal to compare to. 

ExponentialWeighting.png

As you can see, as the forgetting factor increases, the more attenuated the noise is. At a forgetting factor of .5, the Exponential weighting method is good about keeping the flexing dips in the signal while still smoothing out the data

                        Weighted

                      Moving Average

             One the first difference equation we tried was a type of weighted moving average

Screen Shot 2020-12-09 at 8.13.16 PM.png

We can use the filter(b,a,x) function in Matlab, with a = [1], b = [1/k]/sum(1/k) for integers 1<k<5  in to apply the LCCDE as a filter and get the following result:

​

WeightedSum1overkDistribution.png

​

        OUR CHOICE OF FILTER

Weighted sum seems to not do as good of a job as Exponential Weighting to keep the flexing dips, but does a better job of removing noise than the standard moving average.

​

​

Looking at all the options, it looks like exponential weighting at a forgetting factor of .5 is the best method to use. It will be nearly impossible to get rid of all the noise, but it does a good job of smoothing out the curve and keeping the flexing dips that we desire.

 

To incorporate the exponential weighting filter into arduino or another multicontroller, it is fairly simple.

EMG SENSOR

High Pass Filter

For our EMG data, we decided to take a different approach to filtering out the unwanted noise. After some thinking, we decided on a high pass filter, a method discussed in class. 

​

A high pass filter can be used to filter out some of the low frequency components of a signal. In our case, the high frequency components of our signal are only present during flexes. When we isolate these, then, we are able to much more clearly identify the locations where flexes occur. A plot illustrating the effect of this filter is shown below. 

unfiltered_emg_graph.png
filtered_emg_abs.png

We determined the appropriate signal to filter out by utilizing FFTs, as plotted in the spectrogram below. Noticing that high-frequencies were far more abundant during flexes than the resting state.

spectrogram_button.png
  • Facebook
  • Twitter
  • LinkedIn

©2020 by Prosthetic Arm Design. Proudly created with Wix.com

bottom of page