I'm trying to control the vibration frequency of android phone.
I understand android API provides an interface to control the vibration via ON/OFF patterns:
public void vibrate (long[] pattern, int repeat)
Vibrate with a given pattern.
Pass in an array of ints that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds to wait before turning the vibrator on. The next value indicates the number of milliseconds for which to keep the vibrator on before turning it off. Subsequent values alternate between durations in milliseconds to turn the vibrator off or to turn the vibrator on.
To cause the pattern to repeat, pass the index into the pattern array at which to start the repeat, or -1 to disable repeating.
Therefore, I thought that, to get a vibration frequency N, maybe I can repetitively turn the vibrator on and off N times in one second.
For example, to get a 10-second vibration of 20Hz, I assign the pattern as below:
Vibrator vib = (Vibrator)this.context.getSystemService(Context.VIBRATOR_SERVICE);
...
long[] arrPattern = new long[20*10];
for (int i =0; i<arrPattern.length; ++i) // each duty circle is 50 ms
{
arrPattern[i] = (i%2==0)?1:49;
}
vib.vibrate(pattern, -1);
Base on this naive idea, I have conducted several experiments, in which I set the vibration frequency N to different values and attached an accelerometer to the phone and captured the acceleration data during the vibration.
After transforming these time-domain acceleration data into frequency domain via DFT, I notice there is always a significant power around 10Hz and 175Hz, no matter which vibration frequency I set.
I was wondering why does not it work?