How did you determine the values for a0, a1, a2, b1, b2? I understand that a period of 83 ms results in a frequency of 12 Hz but how do I select base frequency and bandwith etc.? The "dspguide" does not explain this either ...
Axel On Friday, February 12, 2010 7:44:39 AM UTC+1, Frank Weiss wrote: > > I finally got to spend some time on this, if anyone is still interested. > The results are promising. I had to brush up on my DSP skills. The core of > my proof of concept is this: > > /** > * A recursive digital band-pass filter with sampling frequency of 12 Hz, > center 3.6 Hz, bandwidth 3 Hz, > * low cut-off 2.1 Hz, high cut-off 5.1 Hz. > * > * Source: http://www.dspguide.com/ch19/3.htm > */ > class Filter // inner class > extends TimerTask { > private float a0 = (float) 0.535144118; > private float a1 = (float) -0.132788237; > private float a2 = (float) -0.402355882; > private float b1 = (float) -0.154508496; > private float b2 = (float) -0.0625; > private float x_1, x_2, y_1, y_2; // x_1 means x[n-1], etc. > @Override > public void run() { > float x_0 = currentInput; // from the enclosing Activity > float y_0 = a0 * x_0 + a1 * x_1 + a2 * x_2 > + b1 * y_1 + b2 * y_2; > currentOutput = y_0; // to the enclosing Activity > x_2 = x_1; > x_1 = x_0; > y_2 = y_1; > y_1 = y_0; > } > } > > I ran this on a java.util.Timer at 83 ms period, using the highest > accelerometer sampling of about 10 ms on a Droid. I only used the X axis > for the proof of concept. For testing, I displayed the RMS of the > currentFilter output in a horizontal progress bar. The bar remains at zero > when the device is stationary, < 10% at most movements, including when the > accelerometer X is +9, when the device is gently tapped on the X axis, or > when the vibrator kicks in by changing the ringer volume. It goes to 100% > when the device is shaken at a good 2 Hz or so along the X axis by hand. > Checking the cut-off frequency (aside from taps and vibrator) is not really > possibly manually. I did run into some forced closes, probably because in > the proof of concept I didn't handle the timer in the Activity lifecycle > correctly. The main problem is the battery use is very high, but this may > be because of some other processing in my code in the sensor event listener. > > Let me know if you guys are still interested in detecting shake and if you > have any questions. I'll try to post the the complete demo code when I get > some time. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

