Skip to content

Signal Noise and Noise Filters

KalebKE edited this page Sep 4, 2016 · 1 revision

Signal Noise:

Android devices black-box (meaning we have no idea what is actually going on under the hood, we just get the sensor outputs) their sensor implementations and they vary by the model and manufacturer. Filters may or may not be applied to sensors before providing an output, and some sensors even have filters designed into them. It is useful to have some idea of what kind of filtering is already occurring in cases where we would like to do filtering of our own. Knowing how much noise exists on the sensor outputs is a good place to start.

A fair amount of information can be gained by determining what hardware is being used on the Android device and then referring to data sheets to determine the expected noise density of the sensor. The noise density, denoted in units of ug/sqrt(Hz), is defined as the noise per unit of square root bandwidth and can be used to determine the expected noise output from a sensor. To determine the expected noise output from noise density, we take the equivalent noise bandwidth, B, of the output filter. The equivalent noise bandwidth of a filter is the -3dB bandwidth multiplied by a coefficient corresponding to the order of the filter. The coefficients are as follows:

  • B = 1.57 * f-3dB for a 1st order filter
  • B = 1.11 * f-3dB for a 2nd order
  • B = 1.05 * f-3dB for a 3rd order filter
  • B = 1.025 * f-3dB for a 4th order filter

Low-Pass Filters:

A low-pass filter eliminates all frequencies above a cut-off frequency, while all other frequencies pass through unaltered. This makes them ideal for eliminating noise that occurs above a certain frequency. A first order filter reduces the signal amplitude by half every time the frequency doubles. A second order filter attenuates higher frequencies more steeply resulting in a signal that is one fourth the original level every time the frequency doubles.

There are different versions of a low-pass filter, but a common implementation found on Wikipedia is xOld = xOld * alpha + (1-alpha) * xNew. When alpha is very small, the effect of the filter is small, the response is very quick and changes in the input are allowed to build up very quickly. When alpha is close to 1, the effect of the filter is large, the response is very slow and changes in the input are allowed to build up very slowly.

Implemented in Java, the low-pass filter looks like this:

public class LowPassFilter
{
    private float alpha;
    private float[] acceleration;
     
    public float[] lowPassFilter(float[] input)
    {
        // Update the Android Developer low-pass filter
        // y[i] = y[i] * alpha + (1 - alpha) * x[i]
        this.acceleration[0] = alpha * acceleration[0]
                + (1 - alpha) * input[0];
        this.acceleration[1] = alpha * acceleration[1]
                + (1 - alpha) * input[1];
        this.acceleration[2] = alpha * acceleration[2]
                + (1 - alpha) * input[2];
         
        return acceleration;
    }
}

Testing With Android:

Applying low-pass filters to Android accelerometers is unfortunately not as straightforward as setting alpha to a static value and moving on. Android devices are equipped with different acceleration sensors, each with their own noise density and output frequency, and this means that more attention needs to be given to the alpha value as these factors will change the behavior of the low-pass filter, however this is beyond the scope of this article.

Android Accelerometer Specifications:

Device Sensor Noise Density Maximum Output Frequency
Nexus 4 MPU-6050 400ug/sqrt(Hz) 193Hz
Galaxy S4 Bosch Sensortec 150ug/sqrt(Hz) 100Hz
Droid Razr STMircoelectronics LIS2DH 220ug/sqrt(Hz) 50Hz

Android Accelerometer LPF Results:

The results from testing the noise on the devices acceleration sensors correlates with the specified noise densities. In the case of an accelerometer, if you apply a 50 Hz first order low pass filter to the outputs of Nexus 4 MPU-6050 accelerometer (ND = 400 ug/sqrt(Hz)) the expected noise would be (400 ug/sqrt(Hz)) * sqrt(1.57 *50 Hz) = 3544 ug. This is the RMS sensor dependent noise expected on the outputs of the MPU-6050. The actual noise seen on the sensor outputs may be larger than this reported error due to environmental noise (thermal, Vdd regulation, mechanical accelerations) on the sensor.

Device Expected Noise Measured Noise Error
Nexus 4 3544 ug 2390 ug 48%
Galaxy S4 1329 ug 1430 ug 8%
Droid Razr 1949 ug 1680 ug 16%

Note that the error for the Nexus 4 is significantly higher than the GS4 or Droid Razr. It is possible that the Nexus 4 is filtering the acceleration sensor where the other two devices are not.